Shop OBEX P1 Docs P2 Docs Learn Events
Running two programs at the same time — Parallax Forums

Running two programs at the same time

ArchiverArchiver Posts: 46,084
edited 2004-04-25 16:09 in General Discussion
Hi I am looking to run two programs at the same time with a BS2. I can
do it with a quick tune and wheels but I know there has to be a command
that I can use to make two programs run at the same time. Can anyone
help?
Thanks Mark

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2004-04-23 15:41
    I'm not being flip: if you want to run TWO separate programs AT THE SAME
    TIME, you will need two BASIC Stamps. You can use any of the multi-slot
    BASIC Stamp modules (BS2e, BS2sx, BS2p, BS2pe) to hold multiple programs
    (up to eight) and jump between them, but only one is ever running at a
    given time.

    -- Jon Williams
    -- Applications Engineer, Parallax
    -- Dallas Office


    Original Message
    From: MARK DEVINE [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=LnEoD8Y4i7CEvburfUj9lwVJ4d1-7I7CLLoWJn1YmHK84slpfljP52qn59JO6lR-uSnEZ5ttJBdmLQn_yg]mdevine@s...[/url
    Sent: Thursday, April 22, 2004 10:05 PM
    To: basicstamps@yahoogroups.com
    Subject: [noparse][[/noparse]basicstamps] Running two programs at the same time



    Hi I am looking to run two programs at the same time with a BS2. I can
    do it with a quick tune and wheels but I know there has to be a command
    that I can use to make two programs run at the same time. Can anyone
    help? Thanks Mark
  • ArchiverArchiver Posts: 46,084
    edited 2004-04-23 23:33
    Thanks John,
    Maybe I can reword it to "more than one subroutine running at the same time"? I
    realize the stamp can run one (program) but I would like to have multiple
    outputs coming from one board at the same time. Is there a command that can be
    used to run two or three or more subroutines at one time? Or is this a case of
    not having enough voltage to drive multipule ouputs. I totally understand your
    not being flip I am just trying to get the most out of the board that I can.
    BS2 BOE.
    Thanks Mark


    Original Message
    From: Jon Williams [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=qmG9YM-Y0iburBYYp9kC_w5zkeVIeuOV-QWUCLHktC2_NvAAXPCDYhwQeOVTgjgHnwVx6ZIbds1i71AvDA]jwilliams@p...[/url
    Sent: Fri 4/23/2004 10:41 PM
    To: basicstamps@yahoogroups.com
    Cc:
    Subject: RE: [noparse][[/noparse]basicstamps] Running two programs at the same time



    I'm not being flip: if you want to run TWO separate programs AT THE SAME
    TIME, you will need two BASIC Stamps. You can use any of the multi-slot
    BASIC Stamp modules (BS2e, BS2sx, BS2p, BS2pe) to hold multiple programs
    (up to eight) and jump between them, but only one is ever running at a
    given time.

    -- Jon Williams
    -- Applications Engineer, Parallax
    -- Dallas Office


    Original Message
    From: MARK DEVINE [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=Yr_Z0iTQ047ukRiOov1x4IBwqEbMRGTMud9bFWv8K9GnohrZmdfEWG03tYBpFMdB4RHeZtv40CmjUg]mdevine@s...[/url
    Sent: Thursday, April 22, 2004 10:05 PM
    To: basicstamps@yahoogroups.com
    Subject: [noparse][[/noparse]basicstamps] Running two programs at the same time



    Hi I am looking to run two programs at the same time with a BS2. I can
    do it with a quick tune and wheels but I know there has to be a command
    that I can use to make two programs run at the same time. Can anyone
    help? Thanks Mark


    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.

    Yahoo! Groups Links









    [noparse][[/noparse]Non-text portions of this message have been removed]
  • ArchiverArchiver Posts: 46,084
    edited 2004-04-23 23:55
    Well, the BS2 is a single-tasking beast.
    Thus, you can only run one 'thread' of execution
    at a time. However, you CAN change a set of
    output pins at one time --

    MyPins VAR OUTL ' OutL is P7..P0

    DIRL = $FF ' I THINK this is output

    MyPins = $F0
    MyPins = $0F

    (This changes P7..P4 to 1's (high), then
    changes them to 0's (low)).

    If you want to use PULSOUT, or SEROUT, then
    you can only send on one pin, or send data
    on one pin at a time.




    --- In basicstamps@yahoogroups.com, "MARK DEVINE" <mdevine@s...>
    wrote:
    > Thanks John,
    > Maybe I can reword it to "more than one subroutine running at the
    same time"? I realize the stamp can run one (program) but I would
    like to have multiple outputs coming from one board at the same
    time. Is there a command that can be used to run two or three or
    more subroutines at one time? Or is this a case of not having enough
    voltage to drive multipule ouputs. I totally understand your not
    being flip I am just trying to get the most out of the board that I
    can. BS2 BOE.
    > Thanks Mark
    >
    >
    >
    Original Message
    > From: Jon Williams [noparse][[/noparse]mailto:jwilliams@p...]
    > Sent: Fri 4/23/2004 10:41 PM
    > To: basicstamps@yahoogroups.com
    > Cc:
    > Subject: RE: [noparse][[/noparse]basicstamps] Running two programs at the same
    time
    >
    >
    >
    > I'm not being flip: if you want to run TWO separate programs
    AT THE SAME
    > TIME, you will need two BASIC Stamps. You can use any of the
    multi-slot
    > BASIC Stamp modules (BS2e, BS2sx, BS2p, BS2pe) to hold
    multiple programs
    > (up to eight) and jump between them, but only one is ever
    running at a
    > given time.
    >
    > -- Jon Williams
    > -- Applications Engineer, Parallax
    > -- Dallas Office
    >
    >
    >
    Original Message
    > From: MARK DEVINE [noparse][[/noparse]mailto:mdevine@s...]
    > Sent: Thursday, April 22, 2004 10:05 PM
    > To: basicstamps@yahoogroups.com
    > Subject: [noparse][[/noparse]basicstamps] Running two programs at the same time
    >
    >
    >
    > Hi I am looking to run two programs at the same time with a
    BS2. I can
    > do it with a quick tune and wheels but I know there has to be
    a command
    > that I can use to make two programs run at the same time.
    Can anyone
    > help? Thanks Mark
    >
    >
    > 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.
    >
    > Yahoo! Groups Links
    >
    >
    >
    >
    >
    >
    >
    >
    >
    > [noparse][[/noparse]Non-text portions of this message have been removed]
  • ArchiverArchiver Posts: 46,084
    edited 2004-04-24 00:05
    No, in computer terms, the BASIC Stamp is single-threaded, it can do
    only on thing at a time (so running two subroutines is the same as
    running two programs -- you can't do it). Now, one of those things you
    can do it turn multiple outputs on or off. For example, if I want to
    make P0-P7 outputs, I do this:

    DIRL = %11111111

    No I can control the IO bits in parallel. If I want to make P0 and P3
    high, while others remain low, I can do this:

    OUTL = %00001001

    Perhaps the way you're posing your question is where we're getting
    sideways. What, specifically, do you want to do? BTW, have you read
    through the literature we make available for download? ... there's lots
    of good stuff that will give you a good idea of what you can do, and
    probably show you things that you didn't think were possible. Be sure
    to checkout our Nuts & Volts reprints as well -- over 100.

    -- Jon Williams
    -- Applications Engineer, Parallax
    -- Dallas Office


    Original Message
    From: MARK DEVINE [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=otFpGL90l6Cy8krGEaBl0I367m_91g7ff0tp9SRQQtDzWwfjO8LHivDKT5FyAwuLgTYvbEjrmgqxjTnd]mdevine@s...[/url
    Sent: Friday, April 23, 2004 5:34 PM
    To: basicstamps@yahoogroups.com; basicstamps@yahoogroups.com
    Subject: RE: [noparse][[/noparse]basicstamps] Running two programs at the same time


    Thanks John,

    Maybe I can reword it to "more than one subroutine running at the same
    time"? I realize the stamp can run one (program) but I would like to
    have multiple outputs coming from one board at the same time. Is there
    a command that can be used to run two or three or more subroutines at
    one time? Or is this a case of not having enough voltage to drive
    multipule ouputs. I totally understand your not being flip I am just
    trying to get the most out of the board that I can. BS2 BOE.

    Thanks Mark
  • ArchiverArchiver Posts: 46,084
    edited 2004-04-24 18:20
    > Maybe I can reword it to "more than one subroutine running at the same time"?
    > I realize the stamp can run one (program) but I would like to have multiple
    > outputs coming from one board at the same time. Is there a command that can
    > be used to run two or three or more subroutines at one time? Or is this a
    > case of not having enough voltage to drive multiple outputs. I totally
    > understand your not being flip I am just trying to get the most out of the
    > board that I can. BS2 BOE.

    I don't think that changing your wording will change the answer. The BS2
    doesn't support multi-threading. Period. If you really want to do that then
    you should checkout the Javelin Stamp. I'm just getting into it so I haven't
    investigated all the details but the doc and a few of the source programs
    appear to support the rumor that will does support multi-threading.

    --
    Enjoy,
    George Warner,
    Schizophrenic Optimization Scientists
    Apple Developer Technical Support (DTS)
  • ArchiverArchiver Posts: 46,084
    edited 2004-04-24 18:33
    Typical micro doing more than one thing at a time is when the device has what
    is called interupts.

    Since the Stamp does not have interupts, it would be difficult, but not
    impossible to do multiple tasks at once.

    To do multiple tasks at once, it would require these tasks are interleaved
    within the code.....something very difficult to program effectively IMO.

    Ken
    __________________________--
    > I realize the stamp can run one (program) but I would like to have multiple
    > outputs coming from one board at the same time. Is there a command that can
    > be used to run two or three or more subroutines at one time? Or is this a
    > case of not having enough voltage to drive multiple outputs. I totally
    > understand your not being flip I am just trying to get the most out of the
    > board that I can. BS2 BOE.


    [noparse][[/noparse]Non-text portions of this message have been removed]
  • ArchiverArchiver Posts: 46,084
    edited 2004-04-25 16:09
    I will respectfully disagree. Using BRANCH (or now ON..GOTO or
    ON...GOSUB) is is quite possible to create very responsive code that
    "appears" to be doing many things at once, and can dynamically change
    under various conditions. Of course there are limits, nobody has every
    accused the BASIC Stamp of running too fast....

    Just to give you a rough idea of a structure that I frequently use in my
    programs (psuedo-code):


    Main:
    DO
    ' do really important task here
    ON task GOSUB Task1, Task2, Task3 ....
    LOOP


    Task1:
    ' do task code
    IF (some_condition) THEN
    task = task_that_now_has_to_run_next
    ELSE
    ' just point to next task
    task = task + 1 // MaxTask
    ENDIF
    RETURN


    -- Jon Williams
    -- Applications Engineer, Parallax
    -- Dallas Office


    Original Message
    From: smartdim@a... [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=OWTsfGsAPgPY5q0nTLIfMmp07dXNO_yq-e_XdJTqJu4jOSklYfp0H85JaGOJFhpHI9swqGTZgHmoig]smartdim@a...[/url
    Sent: Saturday, April 24, 2004 12:34 PM
    To: basicstamps@yahoogroups.com
    Subject: Re: [noparse][[/noparse]basicstamps] RE: Running two programs at the same time


    <snip>

    To do multiple tasks at once, it would require these tasks are
    interleaved
    within the code.....something very difficult to program effectively IMO.

    Ken
    __________________________--
Sign In or Register to comment.