November 22, 2024, 02:27:48 PM

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.


Electric Chair - Program Request

Started by WolfManor, October 28, 2007, 01:39:58 PM

Previous topic - Next topic

WolfManor

Jon,

One final request for a program for this Halloween. 

I have this electric chair and some extra boards and equipment so I wanted to add some animations to this if possible.

Boards:
-Prop-1
-RC-4 (%11)
-AP-8 (%11)
-PIR - Trigger
-NO (Momentary) Push Button Trigger - If I have someone near the "Switch" then they will throw it.  If not I want it to be able to start upon PIR.
-NO (Momentary) Push Button STOP Trigger - (See Note at the bottom)

Script Details:
1. Trigger - Either by PIR or NO (momentary) Push Button.  I will likely only use one or the other at a time, but figured they could be preset to seperate PINs.

2.  Sound starts on AP-8 (Location 0) - This is going to be one sound that runs the duration.  If possible have the program get the length of the sound and stop the following things at that end of the sound.

3.  As the sound starts the Cylinder on OUT0 will start randomly bouncing the body.  (This cylinder will be mounted to the tail bone of the body and will be a simple up and down movement). The throw is about 2" so it can move fairly quickly.

4. As the Sound starts I also need to start a Random blinking of K1 on the RC-4.  This is a Strobe light that sits under the hood of the chair and on the head of the body.

5.  After 3 seconds (Adjustable Time) the fogger start and continue to the end of the sound.  Fogger will be K2 on the RC-4.

6.  Once the sound ends have everything reset (Or see note below)

7.  Wait for 25 seconds to allow rest before nest "Victim."

NOTE:  Is there a way to put in a STOP button?  Example, I have a "Switch" that is a large knife type switch and it will trigger the start, but I would like to be able to trigger the stop as well.  Is that possible?  This would be a NO (momentary) push button.

Thanks!
Steve

JonnyMac

Do you have some extra servo extender cables?  I'm thinking that it would be better to go direct to the manual connections on   Also, it would be much better to time your audio versus polling the AP-8 as that process takes a lot of time an reduces the quickness of the cylinder and strobe light flashing.  Let me know.
Jon McPhalen
EFX-TEK Hollywood Office

JonnyMac

October 28, 2007, 02:51:40 PM #2 Last Edit: October 28, 2007, 03:01:56 PM by JonnyMac
Here's the program that assumes you will use direct (versus serial) control over the two channels on the RC-4 -- this allows for fast switching of the strobe lamp.

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


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


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


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

SYMBOL  Sio             = 7                     ' SETUP = out; no ULN
SYMBOL  PIR             = PIN6                  ' SETUP = DN
SYMBOL  Trigger         = PIN5                  ' manual trigger
SYMBOL  ESTop           = PIN4                  ' emergency stop
SYMBOL  NotUsed3        = PIN3
SYMBOL  Fogger          = PIN2                  ' connect to RC-4.X2
SYMBOL  Strobe          = PIN1                  ' connect to RC-4.X1
SYMBOL  Valve           = PIN0                  ' mannequin bouncer


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

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

SYMBOL  Yes             = 1
SYMBOL  No              = 0

SYMBOL  Baud            = OT2400


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

SYMBOL  delay           = W3                    ' bounce delay
SYMBOL  timer           = W4                    ' work timer(s)
SYMBOL   tmrLo          =  B8
SYMBOL   tmrHi          =  B9
SYMBOL  lottery         = W5                    ' random value


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

Reset:
  PINS = %0000000                               ' clear outputs
  DIRS = %0000111                               ' configure outputs

  SEROUT Sio, Baud, ("!!!!!!!AP8", 255, "X")

  PAUSE 25000
  timer = 0                                     ' clear timer(s)


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

Main:
  RANDOM lottery                                ' stir random value
  PAUSE 10

  tmrLo = tmrLo + 10 * PIR                      ' check PIR
  IF tmrLo = 250 THEN Start_Show

  tmrHi = tmrHi + 10 * Trigger                  ' check manual trigger
  IF tmrHi < 250 THEN Main


Start_Show:
  SEROUT Sio, Baud, ("!AP8", %11, "P", 0)       ' start audio
  timer = 0                                     ' reset show timer

Run_Show:
  PAUSE 45                                      ' tuned for 50 ms loop
  RANDOM lottery
  Strobe = lottery

Check_Bounce:
  IF delay > 0 THEN Update_Bounce_Timer
    delay = lottery // 101 + 100                ' set milliseconds
    delay = delay / 50                          ' convert to loops
    Valve = Valve ^ 1                           ' toggle

Update_Bounce_Timer:
  delay = delay - 1

Check_Fogger:
  IF timer < 3000 THEN Check_EStop              ' skip if not ready
    Fogger = IsOn

Check_EStop:
  IF EStop = Yes THEN Reset                     ' bail out on e-stop

Check_Timer:
  timer = timer + 50                            ' add loop timing
  IF timer < 30000 THEN Run_Show                ' adjust for audio
    GOTO Reset


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


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

WolfManor

Jon,

I believe that I have a couple of extra wires (If not I will figure something out).  Just to clarify the connections, I would take the Servo connections for PIN1 and PIN2 (Not the OUTs) directly to the manual connections (Three pin Servo plugs X1 and X2) on the RC-4 board.  Should I still run a Serial connection through the RC-4 and then to the AP-8?  I am guessing that I should just run the Prop-1 to the AP-8 as the RC-4 is getting the manual connections.

This looks pretty straight forward based on the documentation (That rarely read thing you provide to everyone for FREE)  LOL.

I plan on working on this tomorrow.  This should go quick as I have everything already.

I will let you know if I have any problems or questions.

Thanks again!



Steve

JonnyMac

Yes, connect PIN1 and PIN2 to X1 and X2 respectively, but don't use the serial connector on the RC-4 -- there are no serial messages going to it.  The relays are being powered directly from the PINx ports -- by design.  This is how I setup the program on my desk to watch things (in fact, I used one of the spares connected to PIN0 [valve] just so I had a visual indicator).  As you correctly surmised, the only device connected to PIN7 is the AP-8.
Jon McPhalen
EFX-TEK Hollywood Office