November 22, 2024, 04:06:42 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.


simple pneumatic with sound

Started by lottafun4u, September 06, 2007, 01:36:56 PM

Previous topic - Next topic

lottafun4u

okay john, most of our props in park use one cylinder and sound trigger by pir sensors,below is a sample from there i can change times as needed and get 20 or so controllers up real fast.
prop is triggered  by pir
delay of one second
cylinder is triggered for 3 seconds
sound comes on for same amount of time as cylinder using your sound boards
sequence ends and cannot be restarted for 30 seconds to prevent retripping by guest
thanks for the help

JonnyMac

September 06, 2007, 02:35:11 PM #1 Last Edit: September 06, 2007, 04:16:17 PM by JonnyMac
Two things:

1) My name is spelled J-O-N -- no H appears anywhere within...  ;D (the other John does in fact have an H in his name)

2) I can write "nicer" programs (and give them more appropriate names) if you'll also tell me the intent of the prop instead of just describing the mechanics.  What does this program do?

Here's a simple program that does what you ask.

' =========================================================================
'
'   File...... LottaFun_1.BS1
'   Purpose...
'   Author.... Jon Williams, EFX-TEK (www.efx-tek.com)
'   E-mail.... jwilliams@efx-tek.com
'   Started...
'   Updated... 06 SEP 2007
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


' -----[ Program Description ]---------------------------------------------
'
' Note: Serial communications on P7 requires the replacement of the ULN2803
'       with a ULN2003, or the removal of pin 1 of the ULN2803.
'
' Note: All delays are expressed in milliseconds (1/1000 sec), hence a
'       delay value of 20000 is equal to 20 seconds.


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


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

SYMBOL  Sio             = 7                     ' remove setup jumper
SYMBOL  PIR             = PIN6                  ' P6 SETUP = DN
SYMBOL  Cylinder        = PIN0                  ' connect to OUT0


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

SYMBOL  IsOn            = 1
SYMBOL  IsOff           = 0

SYMBOL  OffDelay        = 30000                 ' 30 seconds


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

SYMBOL  timer           = B2                    ' for PIR deboucing


' -----[ EEPROM Data ]-----------------------------------------------------


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

Reset:
  PINS = %00000000                              ' clear everything
  DIRS = %00000001                              ' make P0 an output

  PAUSE OffDelay                                ' delay between triggers
  timer = 0                                     ' clear timer


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

Main:
  PAUSE 10                                      ' loop pad
  timer = timer + 10 * PIR                      ' update debounce timer
  IF timer < 250 THEN Main                      ' wait for valid signal

Start_Sound:
  SEROUT Sio, OT2400, ("!AP8", %00, "P", 0)     ' start sound 0

Activate:
  Cylinder = IsOn
  PAUSE 3000
  Cylinder = IsOff

  GOTO Reset


Note that if your sound is longer than 3 seconds it will keep running during the 30 second post delay.
Jon McPhalen
EFX-TEK Hollywood Office