November 23, 2024, 11:24:32 AM

News:

Got VSA?  Want to use your Prop-SX?  Now you can!  See the VSA section of the Library forum for Prop-SX code that works with VSA.


Another Electric Chair Program Request

Started by LeggyGhoul, October 16, 2009, 11:43:42 AM

Previous topic - Next topic

LeggyGhoul

Hi everyone,
I have built an electric chair prop and will be using a Prop-1 and RC-4 to control the elements. I was hoping to have a more complete understanding of the programming by now, but no luck  ???
I saw another program on this board for an electric chair that is close, but I have no idea how to modify it to suit my needs. (I will paste it at the end for reference)
This is what I'm using and hope to achieve:

Prop-1, RC-4, PIR trigger, Cowlacious CAR/P 300
OUT0--Solenoid for electric chair victim
OUT1--sound board
P6--PIR
P7--RC-4
      K1--Strobe light
      K2--Fogger

I would like to trigger the show via the PIR
Once triggered, the strobe, sound clip and thrashing of the victim will all start (random movement on the victim)
The sound clip is 17 seconds long, so after 15 seconds I would like the fogger to be triggered for 2 seconds
Then the whole thing stops and there is a delay of 1 minute before it is able to be triggered again.

Any help would be most appreciated.
Thank you!


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


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

SYMBOL  Trigger         = PIN6                  ' SETUP = DN
SYMBOL  CARP            = PIN5

SYMBOL  Fogger          = PIN2
SYMBOL  Strobe          = PIN1
SYMBOL  Thrasher        = PIN0


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

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

SYMBOL  Yes             = 1
SYMBOL  No              = 0

SYMBOL  ThrashTime      = 20000                 ' 20 seconds


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

SYMBOL  delay           = W3                    ' thrash cycle timing
SYMBOL  timer           = W4                    ' event timing
SYMBOL  lottery         = W5                    ' random value


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

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

  PAUSE 15000                                   ' reset delay


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

Main:
  timer = 0                                     ' reset timer

Check_Trigger:
  PAUSE 5                                       ' loop pad
  timer = timer + 5 * Trigger                   ' update timer
  IF timer < 100 THEN Check_Trigger             ' wait for 0.1 sec input

Start_Audio:
  CARP = IsOn                                   ' pulse to start CAR/P-300
  PAUSE 100
  CARP = IsOff
  PAUSE 22000                                   ' audio run time (20 secs)

  timer = 0                                     ' reset timer
  Strobe = IsOn

Thrash_Baby:
  RANDOM lottery
  delay = lottery // 201 + 50                   ' between 50 and 250 ms
  Thrasher = 1 - Thrasher                       ' flip cylinder status
  PAUSE delay                                   ' hold
  timer = timer + delay                         ' update timer

Check_Fog_Start:
  IF timer < 3000 THEN Thrash_Baby              ' time to start fogger?
    Fogger = IsOn                               ' yes

Check_Fog_End:
  IF timer < 5000 THEN Thrash_Baby              ' time to stop fogger?
    Fogger = IsOff                              ' yes

Check_Thrash_End:
  IF timer < ThrashTime THEN Thrash_Baby        ' done?
    GOTO Reset                                  ' yes, clear everthing


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


JonnyMac

You don't need to provide reference programs... we're pretty good at that stuff!  ;D  What you should tell us, though, is what kind of audio board you're using!  Based on the other program I'll assume (you know what that does....) that you audio board will take a pulse start. 

Here's a program that should do what you want.  Be mindful of the P7 SETUP jumper position as well as clipping pin 1 from the ULN2803 so that you can "talk" to the RC-4.

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


' -----[ Program Description ]---------------------------------------------
'
' Sio     :: Serial IO to EFX-TEK accessories (RC-4, FC-4, etc.)
'            -- clip pin 1 of ULN2803 or replace with ULN2003
'
' Trigger :: Parallax-compatible PIR or N.O. button (mat switch, etc.)
'            -- connect N.O. button between P6.W and P6.R


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

SYMBOL  Sio             = 7                     ' SETUP = UP, ULN = No
SYMBOL  Trigger         = PIN6                  ' SETUP = DN

SYMBOL  Audio           = PIN1
SYMBOL  Thrasher        = PIN0


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

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

SYMBOL  Yes             = 1
SYMBOL  No              = 0

SYMBOL  Baud            = OT2400                ' for EFX-TEK boards


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

SYMBOL  relays          = B0
SYMBOL   Strobe         =  BIT0                 ' on K1
SYMBOL   Fogger         =  BIT1                 ' on K2

SYMBOL  delay           = W3                    ' thrash cycle timing
SYMBOL  timer           = W4                    ' event timing
SYMBOL  lottery         = W5                    ' random value


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

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

  relays = %0000
  GOSUB Set_RC4

  PAUSE 60000                                   ' reset delay


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

Main:
  timer = 0                                     ' reset timer

Check_Trigger:
  RANDOM lottery
  PAUSE 5                                       ' loop pad
  timer = timer + 5 * Trigger                   ' update timer
  IF timer < 100 THEN Check_Trigger             ' wait for 0.1 sec input

Start_Audio:
  Audio = IsOn                                  ' pulse to start audio
  PAUSE 50
  Audio = IsOff

  Strobe = IsOn
  GOSUB Set_RC4

  timer = 0                                     ' reset timer

Thrash_Baby:
  RANDOM lottery
  delay = lottery // 201 + 50                   ' between 50 and 250 ms
  Thrasher = 1 - Thrasher                       ' flip cylinder status
  PAUSE delay                                   ' hold
  timer = timer + delay                         ' update timer

Check_Fog_Start:
  IF timer < 15000 THEN Thrash_Baby             ' time to start fogger?
    IF Fogger = IsOn THEN Check_Thrash_End      ' skip if already on
      Fogger = IsOn                             ' else turn it on
      GOSUB Set_RC4

Check_Thrash_End:
  IF timer < 17000 THEN Thrash_Baby             ' done?
    GOTO Reset                                  ' yes, clear everthing


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

Set_RC4:
  SEROUT Sio, Baud, ("!RC4", %00, "S", relays)
  RETURN

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


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

livinlowe

Quote from: LeggyGhoul on October 16, 2009, 11:43:42 AM
Prop-1, RC-4, PIR trigger, Cowlacious CAR/P 300
OUT0--Solenoid for electric chair victim
OUT1--sound board
P6--PIR
P7--RC-4
      K1--Strobe light
      K2--Fogger



He did mention which type of audio board, but you're so good you GUESS right Jon!!  :D
Shawn
Scaring someone with a prop you built -- priceless!

JonnyMac

Chalk one up for me being a little tired... still trying to get my VSA -> EZ-8 converter/downloader done so our friends can do stand-alone animations....

Sorry, gang.
Jon McPhalen
EFX-TEK Hollywood Office