November 23, 2024, 01:58:29 PM

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.


I need help determining correct controller to use.

Started by IMTim, September 21, 2009, 08:09:27 PM

Previous topic - Next topic

IMTim

I was ask to post my question here.  I am trying to determine the correct controller to use.

I am upgrading a haunted house prop with three different events as the people approach the prop.  I made the prop last year when it was controlled by a person with three momentary on push buttons.  This year the guy who runs the haunted house would like it to be all automated, eliminate the inconsistency of the person.  I want to use a PIR to detect the people.  I need a controller that will actuate when the first person in the party approaches, then won't activate again for a couple of minutes to allow that group to go by, then reset for the next group.

To run the audio files I use the Pricom Dreamplayer.  It can play four separate WAV files depending on which trigger is depressed.   Here is the URL to the player.

http://www.pricom.com/Trains/DreamPlayer.shtml

The three events are:

First: Plays the first audio file on the Dreamplayer

Second: Activates the controls for the prop and plays the second audio file.

Third: Plays the third audio on the player.

The prop runs on two 12 vdc motors.  It's a clown that rises up from six feet to nine feet tall and tilts forward toward the people.  Of course making scary noises as it does.  It's currently controlled by limit switches and relays, complicated but it works.  I didn't want to use air due to location and noise.  Eventually I would like to replace the existing controller with a solid state unit but I don't have time this year.

I guess to make the story short, I need something to simulate the three push buttons, but delay after activating each.  I was hoping it would be fairly simple, but the PIR and the 555 timer chips circuits I found are not playing well together.  The PIR is too sensitive and keeps the trigger activated too long.  I have used the PVC pipe trick, it helps but doesn't completely do what I need.

Can something like your PROP-1 Controller do this with three PIRs?
"We had become the thing we hate. We are better dead."

Sparlimb Keelsetter "The Illearth War"

JonnyMac

The Prop-1 can handle three PIRs with no trouble and start your player as well (which takes an input signal that matches the output of the Prop-1).  I'm struggling with your events.  Are these sequential?  Random?  Can more than one even happen simultaneously?  If it's just a matter of playing one event at a time based on which PIR was activated first then it should be easy.  Now... the way we debounce the PIR to prevent false starts means that we could get two active at the same time -- so how do we prioritize?
Jon McPhalen
EFX-TEK Hollywood Office

IMTim

The prop sets on a wooded trail with lots of room.  I plan on spacing out the three PIRs along the trail.  The first sound event happens as they come down the hill and initially see the prop.  The second PIR will be placed around ten feet further down the trail, it will set off the sound and motion, somewhat blocking the trail.  The final PIR will be as they walk past, again another ten feet down the trail, to activate the final sound.  The initial and finally sound files are short, five to ten seconds.  The sound and motion take around 30 seconds to run through the cycle.  So I would like them to be prioritized.

To minimize the detection field I plan on mounting the PIRs in PVC piping.

Thank you for your help.
"We had become the thing we hate. We are better dead."

Sparlimb Keelsetter "The Illearth War"

JonnyMac

You're still a little loose on specifics so this shell program is the best I can do.  Please consult the manual for the audio player vis-a-vis connections to the audio start inputs.  The program is pretty easy and you shouldn't have any trouble adjusting timing, etc.

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


' -----[ Program Description ]---------------------------------------------
'
' Move both SETUP jumpers to the DN or out position
' -- PIRs connect to P0, P1, and P2


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


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

SYMBOL  Motor2          = PIN7                  ' V+/OUT7
SYMBOL  Motor1          = PIN6                  ' V+/OUT6

SYMBOL  SFX3            = PIN5                  ' V+ -> POS, OUT5 --> 3
SYMBOL  SFX2            = PIN4                  ' V+ -> POS, OUT4 --> 2
SYMBOL  SFX1            = PIN3                  ' V+ -> POS, OUT3 --> 1

SYMBOL  PIR3            = PIN2
SYMBOL  PIR2            = PIN1
SYMBOL  PIR1            = PIN0


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

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

SYMBOL  Yes             = 1
SYMBOL  No              = 0


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

SYMBOL  sensors         = B0
SYMBOL   zone1          =  BIT0                 ' PIR #1
SYMBOL   zone2          =  BIT1                 ' PIR #2
SYMBOL   zone3          =  BIT2                 ' PIR #3

SYMBOL  idx             = B1


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

Reset:
  PINS = %00000000                              ' clear all
  DIRS = %11111000                              ' set output pins (1s)

  PAUSE 30000                                   ' inter-show delay


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

Main1:
  GOSUB Scan_Sensors                            ' check PIRs
  IF zone1 = IsOff THEN Main1                   ' is #1 active?
    SFX1 = IsOn                                 ' start audio #1
    PAUSE 50
    SFX1 = IsOff
    PAUSE 5000                                  ' zone delay


Main2:
  GOSUB Scan_Sensors
  IF zone2 = IsOff THEN Main2
    Motor1 = IsOn                               ' start motion
    Motor2 = IsOn
    SFX2 = IsOn                                 ' start audio
    PAUSE 50
    SFX2 = IsOff
    PAUSE 30000                                 ' zone delay
    Motor1 = IsOff
    Motor2 = IsOff


Main3:
  GOSUB Scan_Sensors
  IF zone3 = IsOff THEN Main3
    SFX3 = IsOn
    PAUSE 50
    SFX3 = IsOff
    PAUSE 5000


  GOTO Reset


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

' Scans PIR inputs
' -- inputs must be active for 100ms to be considered valid

Scan_Sensors:
  sensors = %00000111                           ' arm all
  FOR idx = 1 TO 20
    PAUSE 5
    sensors = sensors & PINS                    ' scan inputs
  NEXT
  RETURN


' -----[ User Data ]-------------------------------------------------------
Jon McPhalen
EFX-TEK Hollywood Office

JonnyMac

Here's a slightly modified version.  I was *bothered* by your comment that the prop blocks the trail.  What happens if a sensor fails -- you could get stuck.  This version adds a fail-safe timer to zones 2 and 3 so if a sensor fails or becomes disconnected the prop will reset itself.  Of course, if the zone 1 sensor fails the prop will never start.

BTW... EFX-TEK does no manufacture PIR sensors.  We carry the unit from Parallax as a convenience for our customers.

The value in "timer" is expressed in 0.1s units, so 900 is 90 seconds.

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


' -----[ Program Description ]---------------------------------------------
'
' Move both SETUP jumpers to the DN or out position
' -- PIRs connect to P0, P1, and P2


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


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

SYMBOL  Motor2          = PIN7                  ' V+/OUT7
SYMBOL  Motor1          = PIN6                  ' V+/OUT6

SYMBOL  SFX3            = PIN5                  ' V+ -> POS, OUT5 --> 3
SYMBOL  SFX2            = PIN4                  ' V+ -> POS, OUT4 --> 2
SYMBOL  SFX1            = PIN3                  ' V+ -> POS, OUT3 --> 1

SYMBOL  PIR3            = PIN2
SYMBOL  PIR2            = PIN1
SYMBOL  PIR1            = PIN0


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

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

SYMBOL  Yes             = 1
SYMBOL  No              = 0


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

SYMBOL  sensors         = B0
SYMBOL   zone1          =  BIT0                 ' PIR #1
SYMBOL   zone2          =  BIT1                 ' PIR #2
SYMBOL   zone3          =  BIT2                 ' PIR #3

SYMBOL  idx             = B1

SYMBOL  timer           = W5


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

Power_Up:
  GOTO Show_Delay                               ' let PIRs warm up

Reset:
  PINS = %00000000                              ' clear all
  DIRS = %11111000                              ' set output pins (1s)


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

Main1:
  GOSUB Scan_Sensors                            ' check PIRs
  IF zone1 = IsOff THEN Main1                   ' is #1 active?
    SFX1 = IsOn                                 ' start audio #1
    PAUSE 50
    SFX1 = IsOff
    PAUSE 5000                                  ' zone delay


Main2:
  timer = 0

Check2:
  GOSUB Scan_Sensors
  IF timer = 900 THEN Reset                     ' reset after 90s

  IF zone2 = IsOff THEN Check2
    Motor1 = IsOn                               ' start motion
    Motor2 = IsOn
    SFX2 = IsOn                                 ' start audio
    PAUSE 50
    SFX2 = IsOff
    PAUSE 30000                                 ' zone delay
    Motor1 = IsOff
    Motor2 = IsOff


Main3:
  timer = 0

Check3:
  GOSUB Scan_Sensors
  IF timer = 900 THEN Reset

  IF zone3 = IsOff THEN Main3
    SFX3 = IsOn
    PAUSE 50
    SFX3 = IsOff
    PAUSE 5000


Show_Delay:
  PAUSE 30000
  GOTO Reset


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

' Scans PIR inputs
' -- inputs must be active for 100ms to be considered valid

Scan_Sensors:
  sensors = %00000111                           ' arm all
  FOR idx = 1 TO 20
    PAUSE 5
    sensors = sensors & PINS                    ' scan inputs
  NEXT
  timer = timer + 1                             ' update fail-safe timer
  RETURN


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




Jon McPhalen
EFX-TEK Hollywood Office

IMTim

Thank you for your help.  The prop only slightly blocks the trail when activated.  Once activated the prop will complete it's cycle and can not be reactivated until complete.  The controller I built to control the two 12 volt motors takes care of that.  The first and third events are just sound files, they add atmosphere, and can be dropped out if needed.  I will give it a try.

"We had become the thing we hate. We are better dead."

Sparlimb Keelsetter "The Illearth War"

livinlowe

IMTim-
I think you'll be suprised how versitile the Prop-1 will be to get you prop running. Jon is always great help, but if you have questions just post them and some of the members can help answer questions as well. Welcome to a new addiction!!!   :D
Shawn
Scaring someone with a prop you built -- priceless!

IMTim

I have a question on the following program you gave me.  I had to tweak a few time pauses but it works great.  I include the entire program after my question so it can be referenced if needed.

I pretty much understand the majority of the program.   I remember some of the Basic I use to program on the Commodore Pet way back in High School, yes 1980.
I am not clear on what each line of the following portion of the program does.  The more I understand, the better I'll be able to set up the next controller.  For example what does "For idx = 1 TO 20" mean?


Scan_Sensors:
  sensors = %00000111                           ' arm all
  FOR idx = 1 TO 20
    PAUSE 5
    sensors = sensors & PINS                    ' scan inputs
  NEXT
  timer = timer + 1                             ' update fail-safe timer
  RETURN

Again thanks for all the help.  I've tried many things and the PROP-1 has won me over.  I've talked to the guy that runs the haunted house about buying these next time and not the Maestro controllers we use now.

Tim

Program I'm using now:

' =========================================================================
'
'   File...... Jolly the Clown
'   Purpose... Activate clown prop (motion and sound) and two sound files
'   Author....
'   E-mail....
'   Started... September 29, 2009
'   Updated... October 5, 2009
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


' -----[ Program Description ]---------------------------------------------
'   The prop is set up on a dark trail.  As people approach to within
'   twenty feet of the prop the first PIR will sets off an sound file
'   using a Dream Player from Pricom (it plays four different sound files).
'   Ten feet away from prop a second PIR sets off the motion and second
'   sound file.  The motion is controlled by an existing control system
'   consisting of relays and limit switches.  The momentary closing of the
'   contact from the Prop-1 (SFX2) will cause the prop to cycle through
'   one complete motion of the prop, rise up, tilt forward, dramatic pause
'   tilt back, then lower back down, timed to the sound file.
'   The third PIR is set five feet along the trail after the prop and
'   will activate the third and final sound file. The prop is ready for
'   it's next victim.

' -----[ Revision History ]------------------------------------------------
'   Tweaking time pauses.  Needed a one second pause during activations
'   of SFX1, SFX2 and SFX3 to ensure the Dream Player and prop control
'   circuit was activated.

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

SYMBOL  SFX3            = PIN5                  ' V+ -> POS, OUT5 --> 3
SYMBOL  SFX2            = PIN4                  ' V+ -> POS, OUT4 --> 2
SYMBOL  SFX1            = PIN3                  ' V+ -> POS, OUT3 --> 1

SYMBOL  PIR3            = PIN2
SYMBOL  PIR2            = PIN1
SYMBOL  PIR1            = PIN0


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

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

SYMBOL  Yes             = 1
SYMBOL  No              = 0


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

SYMBOL  sensors         = B0
SYMBOL   zone1          =  BIT0                 ' PIR #1
SYMBOL   zone2          =  BIT1                 ' PIR #2
SYMBOL   zone3          =  BIT2                 ' PIR #3

SYMBOL  idx             = B1

SYMBOL  timer           = W5


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

Power_Up:
  GOTO Show_Delay                               ' let PIRs warm up

Reset:
  PINS = %00000000                              ' clear all
  DIRS = %11111000                              ' set output pins (1s)


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

Main1:
  GOSUB Scan_Sensors                            ' check PIRs
  IF zone1 = IsOff THEN Main1                   ' is #1 active?
    SFX1 = IsOn                                 ' start audio #1
    PAUSE 1000
    SFX1 = IsOff
    PAUSE 5000                                  ' zone delay


Main2:
  timer = 0

Check2:
  GOSUB Scan_Sensors
  IF timer = 900 THEN Reset                     ' reset after 90s

  IF zone2 = IsOff THEN Check2
    SFX2 = IsOn                                 ' start audio
    PAUSE 1000
    SFX2 = IsOff
    PAUSE 30000                                 ' zone delay


Main3:
  timer = 0

Check3:
  GOSUB Scan_Sensors
  IF timer = 900 THEN Reset

  IF zone3 = IsOff THEN Main3
    SFX3 = IsOn
    PAUSE 1000
    SFX3 = IsOff
    PAUSE 5000


Show_Delay:
  PAUSE 30000
  GOTO Reset


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

' Scans PIR inputs
' -- inputs must be active for 100ms to be considered valid

Scan_Sensors:
  sensors = %00000111                           ' arm all
  FOR idx = 1 TO 20
    PAUSE 5
    sensors = sensors & PINS                    ' scan inputs
  NEXT
  timer = timer + 1                             ' update fail-safe timer
  RETURN


' -----[ User Data ]-------------------------------------------------------
"We had become the thing we hate. We are better dead."

Sparlimb Keelsetter "The Illearth War"

BigRez

October 06, 2009, 02:02:16 AM #8 Last Edit: October 06, 2009, 08:56:53 AM by bigrez
Looks like that section of code is determining if any of the three possible sensors have been triggered.

Specifically, the code:
 FOR idx = 1 TO 20
   PAUSE 5
   sensors = sensors & PINS                    ' scan inputs
 NEXT


is set up to perform a loop 20 times.  Each time through, it increments the value of idx (starting at 1), will pause for 5ms and then perform a logical AND operation of the sensor value and the PINS. It's only concerned with pins 0, 1, and 2 and thus the sensor value is set to %00000111 to begin with, each 1 value representing the 3 PIR positions in PINS.  

This is a debouncing routine... twenty times at 5ms each is about 100ms; standard length of time to determine if the trigger is real or not.  A PIR must be triggered the full 100ms in order to be read as triggered. Once the loop completes, you can determine which of the PIRS have been triggered.

JonnyMac

Thanks for providing the great explanation, Mike.

@Tim: The BASIC Stamp Editor has a smart help system.  If you highlight a keyword and then press the F1 key it will open the help to that page and tell you what the keyword does.  Of course, that doesn't help with full code blocks but as you start to understand the language you will begin to make more sense of the code.  Another key to the debounce routine is the & (logical and) operator -- look it up and see if it makes sense to you.

Debouncing an input is always a good idea.  I have to routines I use: one for a single sensor and another (that I used in your program) for multiple sensors.  The idea behind debouncing is to validate the input and not allow the prop to start running due to a noise spike (from RF, another electrical source, etc.).
Jon McPhalen
EFX-TEK Hollywood Office

IMTim

Thanks I appreciate the help and I'll use the internal help files to increase my knowledge.  I'd really like to expand our use of this type of prop controller vice the push button versions.  I think we can be more precise and easier to change than hoping we get the buttons pressed in the correct order.

Tim
"We had become the thing we hate. We are better dead."

Sparlimb Keelsetter "The Illearth War"

JonnyMac

Even though we now have a bit-banger in our inventory, JB and a I tend to favor programmable controllers as well.  There is nothing more fun -- when doing Halloween props -- using the programmability and features like RANDOM to make behavior lifelike (life is no cyclical, it tends to be somewhat random).
Jon McPhalen
EFX-TEK Hollywood Office