November 24, 2024, 05:26:16 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.


MIB Mod Question

Started by machtoo, December 12, 2012, 02:04:03 PM

Previous topic - Next topic

machtoo

Jon,

I used your template as a start and I am trying to use the trainer board and ULN 2003 as a test environment.  I made a simple mod eliminating the ResetPot function and use P6 as the trigger input.  I commented out the code related to ResetDelay that used a Pot input on P6.  Loaded the program and scaled the pot in the editor.  I have a PIR on the header and the trigger button is available also.  Can't seem to get any outputs that I would expect...no LED action on trainer board.  I can't seem to find the pseudo code (specs) of what is supposed to happen physically.  I assumed the start delay is to cause the unit to wait a bit before activating.

Once activated it appears the fog comes on, audio starts but output is controlled by the pulse time. 

Random thrashing of lid and bottom...light in box is on.

A check to see if the audio time has expired and then reset to be ready to go again.

Hope this is close....just can't seem to get it to fire with the PIR (has been checked and is good using another program) or the button.  Is the reset pot delay necessary (IE can it just use the trainer pot for a start delay if needed?)

Have a good holiday!

Here is the code:

               '==============================================================
'
'   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         = PIN6                  ' 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

  PAUSE 20000                                   ' PIR warmup and post delay

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

JonnyMac

I ran the program on a trainer with no problems.  Check your connections and do keep in mind that 20 seconds is longer than you think. I commented out the start-up delay to test the code. It works.
Jon McPhalen
EFX-TEK Hollywood Office

machtoo

After commenting out the Start Delay it triggers and runs.  Thanks...I will experiment with the Start Delay pot code.