Shop OBEX P1 Docs P2 Docs Learn Events
BS2 question - Starting a program from "idle" state? — Parallax Forums

BS2 question - Starting a program from "idle" state?

Otaku1031Otaku1031 Posts: 34
edited 2011-01-21 11:31 in BASIC Stamp
Hi all,
I'm working on the BS2 code for a thermocouple testing program, and am trying to find out how to power up the BS2 OEM board without starting the program. I'd like to have the board power up in an "idle" state, and then start the TC test program when the reset button is pressed. I could just allow the program to run once when the system is powered up, but would prefer that the program be started only on demand. I can't find anything in the BS2 help topics that address this issue. All help and advice is appreciated!

Gary

Comments

  • davejamesdavejames Posts: 4,047
    edited 2011-01-21 09:06
    Otaku,

    I believe the inherant nature of the BS2 is to "power up and run".

    So, to sorta get around that and meet your need of starting the progam when a button is pressed, why not have as the first few lines the code required to poll your "run" switch?

    Then on power-up, the BS2 would immediately begin polling the run switch and execute the remaining code only when pressed.
  • ercoerco Posts: 20,256
    edited 2011-01-21 09:10
    Hmmm... the reset button. I'm not too familiar with the OEM board. You might be able to trick the brownout regulator somehow with a high-value capacitor across the power leads, so that the BS2 doesn't wake up and start running rightaway at powerup.

    Can you live a "start" pushbutton going to any other input pin? That's easily done and no trickery involved.
  • Otaku1031Otaku1031 Posts: 34
    edited 2011-01-21 09:33
    davejames wrote: »
    Otaku,

    I believe the inherant nature of the BS2 is to "power up and run".

    So, to sorta get around that and meet your need of starting the progam when a button is pressed, why not have as the first few lines the code required to poll your "run" switch?

    Then on power-up, the BS2 would immediately begin polling the run switch and execute the remaining code only when pressed.

    Hi James,
    That sounds like a good solution, thanks very much. I'm a bit new to PBasic, so I'm gonna have a lot of questions.

    A bit off-topic, but I'm wondering if there is a way to step through a PBasic program, executing one line of code at a time. I use this feature in VBA - it saves a ton a time trying to find out which line is returning a weird value. I'm using the code to turn on and off various relays and CMOS devices and it would be very helpful if I could step through the code and verify the state of the devices. Again, I couldn't find anything in the help file on this feature.
  • davejamesdavejames Posts: 4,047
    edited 2011-01-21 10:24
    Hi Otaku,

    You're very welcome. :smile: This is the place to ask.

    No, the basic stamp IDE does not provide stepping through the code as in VB.

    The only thing that can come close to it is sprinking a bunch of "DEBUG" statements (read up on that subject in the reference guide) throughout the code and watch the resultant debug screen for results/actions.
  • Otaku1031Otaku1031 Posts: 34
    edited 2011-01-21 11:02
    davejames wrote: »
    Hi Otaku,

    You're very welcome. :smile: This is the place to ask.

    No, the basic stamp IDE does not provide stepping through the code as in VB.

    The only thing that can come close to it is sprinking a bunch of "DEBUG" statements (read up on that subject in the reference guide) throughout the code and watch the resultant debug screen for results/actions.

    Yeah, I was afraid of that. I've been adding a bunch of "STOP" and "DEBUG" commands to verify the states of the CMOS devices. It's messy, but it works. Thanks again!
  • davejamesdavejames Posts: 4,047
    edited 2011-01-21 11:31
    ...don't know if you've the bucks, but there are some "low cost" logic analyzers available.

    I use a Basic Stamp Logic Analyzer (unfortunately a discontinued product :depressed::depressed::depressed:) for monitoring the BS2, and a USBee SX (~$170) for monitoring other devices in my projects.

    I imagine there are other lower cost analyzers around. When I bought the SX last year it was ~$140.
Sign In or Register to comment.