November 24, 2024, 02:17:10 PM

News:

Be sure to checkout our Vixen interfaces in the Library forum -- if you want PC automation at near zero cost, EFX-TEK and Vixen is a great combination of tools.


Monster in Box

Started by cs1245, October 21, 2012, 08:41:58 PM

Previous topic - Next topic

cs1245

1st problem Im experiencing is the MIB program listed below wont stop running - once one cycle is finish is will restart the program until the PIR sensor is removed.  I then tried to redownload the MIB program and then I ran into my 2nd problem.  I went to BASIC Stamp and hit the RUN ( to download the program) and it stated the following error - "expected a label, variant, or instruction" and on the bottom of the screen it stated Error:149-Expected label, variant, or instruction. 
Any thoughts on these 2 issues?
I did try to down load the MIB program onto a diferrent Prop-1 and still the same error.  I also made sure the BS1 serial adapter is connected to the Prop-1 correctly. 


==============================================================
'
'   File...... MIB.BS1
'   Purpose... "Standard" MIB code with variable hold-off and reset delays
'   Author....
'   E-mail....
'   Started...
'   Updated...
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


' -----[ Program Description ]---------------------------------------------


' -----[ Revision History ]------------------------------------------------


' -----[ I/O Definitions ]-------------------------------------------------

SYMBOL  StartPot        = PIN7                  ' No SETUP, No ULN
SYMBOL  ResetPot        = PIN6                  ' No SETUP, No ULN
SYMBOL  Trigger         = PIN5                  ' ULN is pull-down
SYMBOL  Audio           = PIN4                  ' pulsed output
SYMBOL  Light           = PIN3                  ' 12v LED brake light
SYMBOL  Bottom          = PIN2                  ' to cylinder
SYMBOL  Lid             = PIN1                  ' to cylinder
SYMBOL  Fogger          = PIN0                  ' to relay for fogger


' -----[ Constants ]-------------------------------------------------------

SYMBOL  IsOn            = 1                     ' for active-high in/out
SYMBOL  IsOff           = 0

SYMBOL  FogRun          =  2000                 ' 2 seconds
SYMBOL  AudioPulse      =   250                 ' 1/4s pulse for player
SYMBOL  AudioRun        = 10000                 ' audio is 10s

SYMBOL  MinJump         =   100                 ' timing for lid/box jumps
SYMBOL  MaxJump         =   250


' -----[ Variables ]-------------------------------------------------------

SYMBOL  jump            = B2                    ' for cylinders

SYMBOL  timer           = W3                    ' event timer
SYMBOL  delay           = W4                    ' run delay
SYMBOL  lottery         = W5                    ' random #


' -----[ Initialization ]--------------------------------------------------

Reset:
  PINS = %00000000                              ' clear all
  DIRS = %00011111                              ' make P0-P4 outputs

Reset_Delay:
  POT ResetPot, 100, timer                      ' read reset delay pot
  timer = timer * 120                           ' make 0 to ~30s
  PAUSE timer


' -----[ Program Code ]----------------------------------------------------

Main:
  timer = 0                                     ' reset timer

Check_Trigger:
  RANDOM lottery                                ' stir random #
  PAUSE 5                                       ' loop pad
  timer = timer + 5 * Trigger                   ' update timer
  IF timer < 100 THEN Check_Trigger             ' wait for 0.1 sec input

Start_Delay:
  POT StartPot, 100, timer                      ' read start hold-off
  timer = timer * 40                            ' make 0 to ~10s
  PAUSE timer

Start_Fog:
  Fogger = IsOn
  PAUSE FogRun
  Fogger = IsOff

Start_Audio:
  Audio = IsOn
  PAUSE AudioPulse
  Audio = IsOff

  timer = 0                                     ' clear event timer
  Light = IsOn                                  ' light on

Thrash:
  RANDOM lottery                                ' re-stir
  delay = MaxJump - MinJump + 1                 ' get span
  delay = lottery // delay + MinJump            ' calc jump timing

  jump = lottery & %00000110                    ' new cylinder ouputs
  PINS = PINS &/ %00000110 | jump               ' update cylinders

  PAUSE delay                                   ' hold
  timer = timer + delay                         ' update run timer
  IF timer < AudioRun THEN Thrash               ' if not done, go again
    GOTO Reset


' -----[ Subroutines ]-----------------------------------------------------


' -----[ User Data ]-------------------------------------------------------

bsnut

The only thing I can think of is you changed something in your program. I will take a look at your program and see where the error is and I will fix it for you.
William Stefan
The Basic Stamp Nut

bsnut

October 22, 2012, 03:06:40 AM #2 Last Edit: October 22, 2012, 07:49:45 AM by bsnut
QuoteI then tried to redownload the MIB program and then I ran into my 2nd problem.  I went to BASIC Stamp and hit the RUN ( to download the program) and it stated the following error - "expected a label, variant, or instruction" and on the bottom of the screen it stated Error:149-Expected label, variant, or instruction.
I am going to start with this problem first. I ran a syntax check (clicking on the second button to the left of the run button) and didn't get any errors from the Basic Stamp editor in the code you provided.

Now on to this problem below.
Quote1st problem Im experiencing is the MIB program listed below wont stop running - once one cycle is finish is will restart the program until the PIR sensor is removed. 
Here's your fixed code. Your problem was with the variable "timer" it wasn't being reset at the beginning of these labels "Reset_Delay:" and "Start_Delay:"

Just remember, when you use the same variable over again for something else in your program you need to reset it. This was more in likely causing your problem.  But, the best thing is to create 2 other variables, one for the Reset Pot and another for the Start Pot, this way you don't create the problem you are having.

'==============================================================
'
'   File...... MIB.BS1
'   Purpose... "Standard" MIB code with variable hold-off and reset delays
'   Author....
'   E-mail....
'   Started...
'   Updated...
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


' -----[ Program Description ]---------------------------------------------


' -----[ Revision History ]------------------------------------------------


' -----[ I/O Definitions ]-------------------------------------------------

SYMBOL  StartPot        = PIN7                  ' No SETUP, No ULN
SYMBOL  ResetPot        = PIN6                  ' No SETUP, No ULN
SYMBOL  Trigger         = PIN5                  ' ULN is pull-down
SYMBOL  Audio           = PIN4                  ' pulsed output
SYMBOL  Light           = PIN3                  ' 12v LED brake light
SYMBOL  Bottom          = PIN2                  ' to cylinder
SYMBOL  Lid             = PIN1                  ' to cylinder
SYMBOL  Fogger          = PIN0                  ' to relay for fogger


' -----[ Constants ]-------------------------------------------------------

SYMBOL  IsOn            = 1                     ' for active-high in/out
SYMBOL  IsOff           = 0

SYMBOL  FogRun          =  2000                 ' 2 seconds
SYMBOL  AudioPulse      =   250                 ' 1/4s pulse for player
SYMBOL  AudioRun        = 10000                 ' audio is 10s

SYMBOL  MinJump         =   100                 ' timing for lid/box jumps
SYMBOL  MaxJump         =   250


' -----[ Variables ]-------------------------------------------------------

SYMBOL  jump            = B2                    ' for cylinders

SYMBOL  timer           = W3                    ' event timer
SYMBOL  delay           = W4                    ' run delay
SYMBOL  lottery         = W5                    ' random #


' -----[ Initialization ]--------------------------------------------------

Reset:
  PINS = %00000000                              ' clear all
  DIRS = %00011111                              ' make P0-P4 outputs

Reset_Delay:
  timer = 0                                     ' reset timer
  POT ResetPot, 100, timer                      ' read reset delay pot
  timer = timer * 120                           ' make 0 to ~30s
  PAUSE timer


' -----[ Program Code ]----------------------------------------------------

Main:
  timer = 0                                     ' reset timer

Check_Trigger:
  RANDOM lottery                                ' stir random #
  PAUSE 5                                       ' loop pad
  timer = timer + 5 * Trigger                   ' update timer
  IF timer < 100 THEN Check_Trigger             ' wait for 0.1 sec input

Start_Delay:
  timer = 0                                     ' reset timer
  POT StartPot, 100, timer                      ' read start hold-off
  timer = timer * 40                            ' make 0 to ~10s
  PAUSE timer

Start_Fog:
  Fogger = IsOn
  PAUSE FogRun
  Fogger = IsOff

Start_Audio:
  Audio = IsOn
  PAUSE AudioPulse
  Audio = IsOff

  timer = 0                                     ' clear event timer
  Light = IsOn                                  ' light on

Thrash:
  RANDOM lottery                                ' re-stir
  delay = MaxJump - MinJump + 1                 ' get span
  delay = lottery // delay + MinJump            ' calc jump timing

  jump = lottery & %00000110                    ' new cylinder ouputs
  PINS = PINS &/ %00000110 | jump               ' update cylinders

  PAUSE delay                                   ' hold
  timer = timer + delay                         ' update run timer
  IF timer < AudioRun THEN Thrash               ' if not done, go again
    GOTO Reset


' -----[ Subroutines ]-----------------------------------------------------


' -----[ User Data ]-------------------------------------------------------
William Stefan
The Basic Stamp Nut

cs1245

I wont be home until late tonight to try to upload the program into the Prop-1, but would the "defective code" not be transferrable to the Prop-1 by Basic Stamp.  The reason I say that is that last I used this code and it loaded onto the Prop-1 fine and performed commands without incident.  This year I get an error when I try to reinstall the code onto the Prop-1. 

cs1245

With the changes you gave I am now able to load code onto the Prop-1, but I am still experiencing the same problem.  Once I hook up the PIR to Pin 5 with the correct WRB cable hookup, the program keeps cycling without stopping.  I tried a different PIR and still the same issue. 
I have attached 2 pics - let me know if you need better resolution pics.

bsnut

It was a smart idea for you to post the pics of your problem, but for some reason I can't them when I click on the link. Is there a way you can post the two different pics for us to see?

I will test your program code for you to see what it's doing for me. Have you triggered it without using the PIR, by placing a button across P5.R and P5.W?     
William Stefan
The Basic Stamp Nut

bsnut

October 23, 2012, 03:13:48 AM #6 Last Edit: October 23, 2012, 03:15:53 AM by bsnut
I tested both versions of the code, your code and the one I changed for you and didn't find any problems. I even tested with a pushbutton trigger and my PIR and worked fine for me.

The only thing I can think of is something is constantly passing in front of your PIR, even moving the PIR can cause it to trigger too.

Another question for you, do you need the Reset Pot in your prop? If you don't need it we can remove these lines of code


Reset_Delay:
  POT ResetPot, 100, timer                      ' read reset delay pot
  timer = timer * 120                           ' make 0 to ~30s
  PAUSE timer

and replace it with this under the label "Reset".

Reset:
  PINS = %00000000                              ' clear all
  DIRS = %00011111                              ' make P0-P4 outputs

  PAUSE 30000                                   ' warmup and post delay
 

William Stefan
The Basic Stamp Nut

cs1245

October 23, 2012, 07:21:33 AM #7 Last Edit: October 23, 2012, 07:47:44 AM by cs1245
With PIR attached and me hiding behind the monster box it will still trigger it. 

Can you tell how to push button trig the prop-1?  How do i place a button across the P5.R and the P5.W?  Do i take an extra WRB cable and connect to to the P 5 and expose the Red and white wires then touch the together to make the connection?  Otherwise i do have own  EZ-3 and prop pot trainer if those would help manual trigger the prop.

Lastly, with regards to the Reset Pot, how do i know if i need it or not? 

Last year the MIB program Jon wrote last year seemed to work fine, but when i plugged it in this year it didnt.

Let me know if there is an email address i can send those 2 pics to you. 

JonnyMac

PIRs are finicky -- I don't like them at all. When forced to use them I put them in a piece of PVC pipe (with an end-cap) so that the field is narrowed.  Keep in mind those domes are designed to let the PIR see nearly 180 degrees; using the pipe cuts that down and makes them more directional. I find 2" pipe is easy to deal with.

QuoteCan you tell how to push button trig the prop-1?

Connect a normally-open button between P6.W (signal) and P6.R (+5v). You can do this by taking a 14" WRB extender cable, cut it in half (you can make two sensor connections from one cable), then solder some 20-22 guage zip wire to the white and red wires, the other end of the wire goes to the contacts on your normally-open button/switch.

QuoteLastly, with regards to the Reset Pot, how do i know if i need it or not?

That's a design decision, not a tech requirement. If you want it, put it in, otherwise you can use a fixed delay (30s is recommended).

QuoteLast year the MIB program Jon wrote last year seemed to work fine...

I rule!  ;D


Jon McPhalen
EFX-TEK Hollywood Office

cs1245

well i never would have guessed 2 PIR sensors went bad but it is true.  I switched to a third PIR and the program works.  I have even noticed the fog will trigger the PIR so here come a 2" PVC to enclose the PIR.  and yes Jon you do rule.  Thanks to you and BSNut for your prompt help.   

bsnut

I am glad that you got everything working and that's why I agree with Jon's point on PIR sensors. They are just a pain in the you know.

Yes Jon rules and I provide prompt help ;D. That's the whole idea of these forums is to provide prompt help to other forum members
William Stefan
The Basic Stamp Nut

cs1245

Im looking to change the length of time to needed to have a Post Delay.  Once the prop is done it currently can be triggered right away.  Can someone write the line(s) I need to cut and paste into the above program to have 20 sec delay before the prop-1 can be triggered again.  And dont ask me what Im doing, but the MIB seems to be working fine again.  Likely the PIR.  As of now I probably wont need to call you on Monday Jon.  Ill try running the MIB with the pneumatics attached to the lid and bottom of the box and see if the violent shaking the of MIB is affecting the PIR.  Maybe this post delay will help prevent false triggers. 

bsnut

October 28, 2012, 04:10:47 PM #12 Last Edit: October 28, 2012, 04:12:49 PM by bsnut
Here's your Post Delay code for you to place in your program and if you don't need the Reset Pot just remove these lines of code from your program by  commenting out using this ( ' ).

Reset_Delay:
  POT ResetPot, 100, timer                      ' read reset delay pot
  timer = timer * 120                           ' make 0 to ~30s
  PAUSE timer

and replace it with this under the label "Reset".

Reset:
  PINS = %00000000                              ' clear all
  DIRS = %00011111                              ' make P0-P4 outputs

  PAUSE 20000                                   ' PIR warmup and post delay
 


William Stefan
The Basic Stamp Nut

cs1245

Looks like the PIR is acting up.  I think the solution is to have the prop-1  have a post delay of 2 minutes.  I typed into the program in the INITIALIZATION section  below the DIRS line.  Do

PAUSE 240000 and loaded it, but it seems to still trig every 1 minute.

What am I not typing in correctly.
.

JackMan

 Several things wrong. You can't have a value greater than 65535 in a BS1 program, it will ignor it if you do. Your value of 240000 would be 240 seconds or 4 minutes. For a 2 minute pause you need to enter two lines of PAUSE code, each with a value of 60000. You need to enter these in RESET in place of the 20s PAUSE that is already there.