May 18, 2024, 12:04:01 AM

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.


Re: Standardized of MIB Program

Started by cs1245, September 12, 2011, 09:35:09 PM

Previous topic - Next topic

cs1245


     I reviewed the thread on Aug 10, 2010 for the MIB program.  I would like to keep the program you already written, but add the RANDOM program for the cylinder thrashing the bottom of the box.

Here are my definitions:

OUT 0 Relay for Fogger
OUT 1 Cylinder for Box Lid
OUT 2 Cylinder for Box Bottom
OUT 3 Relay for Light
OUT 4 Relay for Cowalicious sound board
OUT 5 LED Break Beam Trigger
OUT 6 Reset Pot
OUT 7 Start Pot

Let me know if I omitted any necessary information to write the program.

One last thing - the program you have written I need to clip the P1 and P2 pins on the ULN2803 - so that would be the 3rd and 4th pin up from the "bottom" of the ULN on the left side. 

Thanks

JonnyMac

We have a lot of MIB programs in our forums.  Please copy-and-paste the version you're interested in into this thread and I'll modify it for you.
Jon McPhalen
EFX-TEK Hollywood Office

cs1245

' =========================================================================
'
'   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 ]---------------------------------------------
'
' Connections:
'
' P7 -   PropPot in Prop-1 mode for start delay
'        * must remove pin 1 of ULN2803
'        * must remove P7 SETUP jumper
'
' P6 -   PropPot in Prop-1 mode for reset delay
'        * must remove pin 2 of ULN2803
'        * must remove P6 SETUP jumper
'
' P5 -   Active-high trigger input
'        * Parallax PIR
'        * N.O. button/mat switch between P5.W and P5.R
'
' OUT4 - Pulse out to audio player
'        * use OUT4/GND to send start pulse to AP-8 (P input)
'        * use V+/OUT4 to send 12v pulse to AP-16 or Cowlacious
'
' OUT3 - Control to 12v light
'        * suggest 12v LED automotive brake light/turn light
'
' OUT2 - Control to 12v light
'        * suggest 12v LED automotive brake light/turn light
'
' OUT1 - To cyclinder that controls lid or box jumping
'
' OUT0 - To relay that controls fogger remove
'        * Be VERY CAREFUL with fogger remote wiring


' -----[ 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  Light2          = PIN3                  ' 12v LED brake light
SYMBOL  Light1          = PIN2                  ' 12v LED brake light
SYMBOL  Box             = 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  flash           = B2                    ' for light flashing

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


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

Reset:
  PINS = %00000000                              ' clear all
  DIRS = %00001111                              ' make P0-P3 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

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

  flash = lottery & %00001100                   ' isolate lights
  PINS = PINS &/ %00001100 | flash              ' update light outputs

  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

September 14, 2011, 07:26:24 AM #3 Last Edit: October 31, 2011, 11:51:49 AM by JonnyMac
Here you go.

You need to clip ULN pins 1 & 2 which are the topmost pins on the left column as you're looking at the board and can read the writing.  See this post for a graphic:
-- http://www.efx-tek.com/php/smf/index.php?topic=130.0

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


Jon McPhalen
EFX-TEK Hollywood Office

cs1245

What position will the red jumpers be on the SETUP for the Prop-1 - (ie two jumpers on both DOWN positions or a different configuration?)

bsnut

Based on the program that Jon did, it states in the comments No Setup, No ULN. This means that you don't need to use the setup jumpers and also need to remove the ULN pins for these two I/O pins on the Prop-1. The reason for this, is that the pullup/ pulldown resistors and ULN will interfere the pot readings.
William Stefan
The Basic Stamp Nut

cs1245

I have 2 questions regarding the definitions.  For clarification I am using ULN2003A (P0 - P7) and I used as reference the ULN Modifications for Serial Comm link on the EFX-TEK main page. 
First question, for the TRIG PIN5 - the definition states remove ULN - so do I clip the left 6th pin up from the bottom slot - (actually PIN 5 if you start counting the bottom slot as Pin 0)?

Second question, will I also clip PIN6 and PIN 7 (the top two left sided pins) as noted in the definitions : No SETUP, No ULN for Pin 6 and Pin 7?


bsnut

October 23, 2011, 01:05:32 AM #7 Last Edit: October 23, 2011, 01:28:21 AM by bsnut
Let me answer your questions for you.
QuoteFirst question, for the TRIG PIN5 - the definition states remove ULN - so do I clip the left 6th pin up from the bottom slot - (actually PIN 5 if you start counting the bottom slot as Pin 0)?
PIN 5 refers to the I/O pin on the Basic Stamp processor, not the ULN pin itself.

QuoteSecond question, will I also clip PIN6 and PIN 7 (the top two left sided pins) as noted in the definitions : No SETUP, No ULN for Pin 6 and Pin 7?
Since, you are using the ULN2003A. Looking the ULN2003A inserted in the socket, leaving Basic Stamp I/O pin7 with nothing in it and the ULN2003A taking the rest of the socket up (ULN pin1 lined up with Basic Stamp I/O pin6) as shown in the attachment. 

You will only need to clip or do what I is bend the ULN pin1 out of the way.

Remember that all IC chips the pin1 is indicated by small dot, which if left of the notch and starts form the dot and start to count up going in counter clockwise. Since the ULN2003A is a 16 pin IC, pin16 would be opposite of pin1.     
William Stefan
The Basic Stamp Nut

JackMan

QuoteFirst question, for the TRIG PIN5 - the definition states remove ULN

No, this is how it was written. You don't need to do anything to the ULN PIN5.

SYMBOL  Trigger         = PIN5                  ' ULN is pull-down

Per Jon's program if you are using a ULN2003 you only need to clip or bend up the top left pin as Bill has stated.

cs1245

I ran the program with PIR sensor and the pin1 bent up (using ULN2003) and the light never came on and the random sequence for the cylinders worked, but the pneumatics never stopped firing - it kept firing in a random pattern. It seemed like there was a moment where the program RESET, but continued to do a loop.  I looked at the program with my inexperienced eye and I dont see an "end point" to the program.  I only want the total tun time of the MIB program to be 15 secs.  Any thoughts on why the light may not be triggering.  I am using a 120V light with a relay soldered to a Radio Shack board. 

cs1245

I was able to fix the light not coming on "issue", but it still seems like the MIB Program cycles every 10-12 secs and never stops cycling and I am unable to trigger the AP16 ( OUT4 connected to the 12-24V terminal on the AP16 and V+ connected to the other open 12-24V terminal on AP16).  Any thoughts?

JonnyMac

Is your trigger stuck?  You can use DEBUG to tell you that.  When triggering external audio devices with a pulse we suggest 250ms -- the AP-16+ has a 150ms debounce period, other players (e.g., Cowlacious) use 250.  250 is safe.  In human terms, a quarter second seems like an instant. 

Using the 12-24 input is the same as pressing the Start button.  Check the AP-16+ by pressing Start to ensure the file does in fact play.
Jon McPhalen
EFX-TEK Hollywood Office

cs1245

Regarding the DEBUG - do you mean downloading the program written in the Prop-1 Controller Documentation PDF and making the I see "Hello World"?  If so, I did it and saw the message and reloaded the MIB Pneumatic Program and even changed out to new PIR Motion Sensor and still no change - it still cycles with out stopping unless I remove the B/R/W connector from the Prop-1 then it stops cycling. 

For the AP16 when I push the START button I get sound out of the speakers, but still no trigger from the OUT4. 

Any thoughts?

JonnyMac

Found it: very subtle error (sorry, my mistake) in setup of the DIRS register; in the original program P4 was not being set to output mode.  The corrected code (added to above listing) is:

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


A pin must be in output mode to send a pulse.
Jon McPhalen
EFX-TEK Hollywood Office

cs1245

Works great now- many compliments from the TOTs.  Thanks Jon.