November 22, 2024, 10:43:09 PM

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.


Prop1 programming electric chair w/ random

Started by premierhauntprops, September 19, 2008, 10:49:50 AM

Previous topic - Next topic

premierhauntprops

Hi, I am looking for some help programming my Prop1 controller to operate my electric chair. I have four solenoids hooked up to two double acting air cylinders. They are connected w/ OUT0 - forward, OUT1 - back, OUT2 - up, & OUT3 - down. I also have an AP-8 sound board wired to OUT4. The program needs to intiate the sound board, wait 5 second and the randomly energize the 4 solenoids for 15 seconds, pause for 9 seconds, and resume the random energizing of the four solenoids for 31 seconds. The forward and back solenoids can't be on at the same time nor can the up & down solenoids for that matter as well. I appreciate your taking time out to review this request and your help is greatly appreciated. Thanks, Sean w/ Premier Haunt Props

JonnyMac

Okay, here's a program to get you started.  Note that I moved the AP-8 connection to P7 so that we can remove the ULN influence that interferes with serial communications.  If you bought a starter kit you received a ULN2008 with the Prop-1 Trainer; replace the ULN2803 that's in the Prop-1 with the ULN2003 and move the P7 SETUP jumper to the UP position, or remove it altogether.

We may need to adjust the timing in the Thrash_Dude subroutine to accommodate your cylinders -- that's easy once everything is connected and basically working.

' =========================================================================
'
'   File...... Electric_Chair-4x.BS1
'   Purpose... Chair uses four valves for Foward/Back/Up/Down control
'   Author.... Jon Williams, EFX-TEK
'              Copyright (c) 2008 EFX-TEK
'              Some Rights Reserved
'              -- see http://creativecommons.org/licenses/by/3.0/
'   E-mail.... jwilliams@efx-tek.com
'   Started...
'   Updated... 19 SEP 2008
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


' -----[ Program Description ]---------------------------------------------


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


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

SYMBOL  Sio             = 7                     ' SETUP = out, use ULN2003
SYMBOL  Trigger         = PIN6                  ' SETUP = DN
SYMBOL  FallDown        = PIN3
SYMBOL  JumpUp          = PIN2
SYMBOL  Back            = PIN1
SYMBOL  Forward         = PIN0


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

SYMBOL  Baud            = OT2400

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


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

SYMBOL  delay           = W3
SYMBOL  timer           = W4
SYMBOL  lottery         = W5
SYMBOL   lottoLo        =  B10
SYMBOL   lottoHi        =  B11


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

Reset:
  PINS = %00000000                              ' clear all outputs
  DIRS = %00001111                              ' make P0-P5 outputs

  SEROUT Sio, Baud, ("!!!!!!AP8", %00, "X")     ' kill audio


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

Main:
  timer = 0                                     ' reset timer

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

Start_Audio:
  SEROUT Sio, Baud, ("!AP8", %00, "P", 0)
  PAUSE 5000

  timer = 15000
  GOSUB Thrash_Dude
  PAUSE 9000

  timer = 31000
  GOSUB Thrash_Dude

  GOTO Reset


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

Thrash_Dude:
  RANDOM lottery                                ' re-stir random
  Forward = lottoLo
  Back = 1 - Forward                            ' make opposite of Forward
  JumpUp = lottoHi
  FallDown = 1 - JumpUp
  RANDOM lottery                                ' re-stir random
  delay = lottery // 151 + 100                  ' 0.1 to 0.25, random
  PAUSE delay
  IF timer < delay THEN Thrashing_Done
    timer = timer - delay
    GOTO Thrash_Dude

Thrashing_Done:
  PINS = IsOff
  RETURN

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


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