Shop OBEX P1 Docs P2 Docs Learn Events
BS2 help for the newbie guy — Parallax Forums

BS2 help for the newbie guy

Daniel BrockmanDaniel Brockman Posts: 6
edited 2011-08-27 08:01 in BASIC Stamp
I guess I should start by telling what I'm trying to accomplish and maybe someone can give me some directions.
As I stated above I have the BS2 and my project that has been handed to me is,
We have a belt system that is moving small rocks from hoppers. When the hopper becomes empty, we want to have it automatically open another hopper and refill the empty. Pretty simple so far, right.
The issue I'm running into is I need to have the BS2 count to 60 seconds before it opens the other hopper, to make sure the current hopper is empty.
Do I need a external time base from let's say a 555 timer circuit or can the BS2 run the program and keep a timer running at the same time. I have tried some senarios but believe this controller being a single threaded device will not do this. If this is the case what controller should I use or is it simpler just to add a external time base. Does Parallyx make a time base module.

Comments

  • FranklinFranklin Posts: 4,747
    edited 2011-08-26 17:23
    For 60 seconds (more or less) you could use a 555 or probably an RC circuit if tou don't need too fine a time. You could also build a counter into the program that would count up and test it for a value equating to 60 seconds. This would require trial and error to get the count right but it is doable.
  • Mike GreenMike Green Posts: 23,101
    edited 2011-08-26 20:31
    You can use a single PAUSE statement for times up to about a minute. The pause time is in milliseconds and can be as large as 65535. That's a little over a minute and is pretty accurate since it's derived from the Stamp's internal clock.

    If you need to do something from time to time while this pause is taking place or if this pause needs to be interrupted under some conditions, you typically use a PAUSE 1000 to produce a one second clock. The PAUSE 1000 is placed in a loop and other (brief) things can be done once a second. If these things take much time to execute, you can adjust the length of the one second pause to compensate.
    for i = 1 to 60  ' where i is some byte variable
       pause 1000
       ' This is where you might check for a pushbutton being pushed or something like that
       ' If the loop is to be terminated, you'd have a goto out of the loop
    next i
    ' Now 60 seconds have gone by
    
  • Daniel BrockmanDaniel Brockman Posts: 6
    edited 2011-08-27 08:01
    Great idea. I'll give that a try. Thanks you guys for getting back to me.
    I really appreciate the help.
Sign In or Register to comment.