November 23, 2024, 12:09:45 AM

News:

You can now use Vixen to program your Prop-1 and Prop-2 controllers!  Get started quickly and easily, without having to learn PBASIC.  Details in the Library forum.


CindyBob-Compatible MIB Program Update

Started by JonnyMac, October 20, 2009, 12:19:23 PM

Previous topic - Next topic

JonnyMac

October 20, 2009, 12:19:23 PM Last Edit: October 27, 2009, 11:22:14 AM by JonnyMac
A new customer called requesting help with his MIB that he's building based on the instructions from the CindyBob web site:

-- http://www.cindybob.com/halloween/mib

He was confused the program and didn't want to use two Prop-Pots.  Just for fun, and to help others, I've written this program that is compatible with the CindyBob MIB project.

Changes:
 -- Uses the Prop-1 Trainer POT for the PIR warm-up and retrigger delay (20 to 60 seconds)
 -- trigger-to-run time delay is randomized
 -- number of cycles to run is randomized
 -- audio start intended for V-Trig input on Cowlacious boards
     * we don't recommend powering the audio board from the ULN; power it directly and start with V-Trig

I think most will find this code far more trim and straightforward than the original while accomplishing the same effect.

' =========================================================================
'
'   File...... CB_MIB_2009.BS1
'   Purpose...
'   Author....
'   E-mail....
'   Started...
'   Updated... 27 OCT 2009
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


' -----[ Program Description ]---------------------------------------------
'
' Holdoff :: POT input (Prop-Pot or from Prop-1 Trainer
'            -- swap ULN2803 with ULN2003
'
' Trigger :: Parallax-compatible PIR or N.O. button (mat switch, etc.)
'            -- connect N.O. button between P6.W and P6.R


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


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

SYMBOL  Holdoff         = 7                     ' SETUP = out, NO ULN
SYMBOL  Trigger         = PIN6                  ' SETUP = DN
SYMBOL  CowAudio        = PIN3                  ' V+/OUT3 to V-Trig @9-12v
SYMBOL  Fog             = PIN2                  ' V+/OUT2 to relay
SYMBOL  Lights          = PIN1                  ' V+/OUT1 to relay
SYMBOL  Motor           = PIN0                  ' V+/OUT0 to relay


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

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

SYMBOL  Yes             = 1
SYMBOL  No              = 0


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

SYMBOL  cycles          = B2

SYMBOL  delay           = W3
SYMBOL  timer           = W4
SYMBOL  lottery         = W5


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

Reset:
  PINS = %00000000                              ' clear all
  DIRS = %00001111                              ' set output pins

  POT Holdoff, 100, delay
  delay = delay * 157 + 20000                   ' 20 to 60 seconds
  PAUSE delay


' -----[ 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

Do_Wait:
  delay = lottery // 3001 + 2000                ' 2 to 5 seconds
  PAUSE delay

  RANDOM lottery                                ' re-stir
  cycles = lottery // 3 + 1                     ' 1 to 3 cycles

Start_Prop:
  CowAudio = IsOn
  Motor = IsOn
  Fog = IsOn

  timer = 0                                     ' reset

Run_Show:
  Lights = 1 - Lights                           ' toggle lights
  RANDOM lottery                                ' restir
  delay = lottery // 251 + 100                  ' 100 to 350ms
  PAUSE delay
  timer = timer + delay
  CowAudio = IsOff                              ' prevent looping

Check_Fog:
  IF timer < 1500 THEN Run_Show                 ' enough fog?
    Fog = IsOff                                 ' yep, turn it off

Check_Show:
  IF timer < 10000 THEN Run_Show                ' audio done?
    cycles = cycles - 1                         ' update cycle count
    IF cycles > 0 THEN Start_Prop               ' more cycles?
      GOTO Reset                                ' nope, we're done


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


' -------------------------------------------------------------------------


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


Jon McPhalen
EFX-TEK Hollywood Office

Remington

I want to thank both the Jon's of EFX_TEK for all your help!!!   

I need to ask a question.. In the PROP-1 CONTROLLER doc. it explains how to program the Prop- 1,  Main: DEBUG " Hello, World!" END    OK, I can under stand that..  but---- do I have to remove that program{ "Hello, World!" }to load the program above this post?

JonnyMac

Downloading a new program overwrites the old one -- no "removal" is required.
Jon McPhalen
EFX-TEK Hollywood Office