November 24, 2024, 06:43:46 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.


Alien Tentacle

Started by vista, September 24, 2010, 08:57:07 PM

Previous topic - Next topic

vista

The art behind this was much harder than the creation or the code. I thought of dozens of hard ways to startle the victims and this way turned out real well. As always Jon bailed me out by writing the code and it uses a prop1, an RC4 to run the solenoid amd a PIR for triggering it.
The first video link is to the more of less finished project with he lights off..
http://www.youtube.com/watch?v=4yRWqxozKCM

This second video link is of the scene with the lights on...
http://www.youtube.com/watch?v=OlXxmI9K7Eo&feature=channel

Vista

If you need the code...   ;D
' =========================================================================
'
'   File......
'   Purpose...
'   Author....
'   E-mail....
'   Started...
'   Updated...
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


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


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


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

SYMBOL  Sio             = 7                     ' SETUP = UP; no ULN
SYMBOL  Trigger         = PIN6                  ' SETUP = DN


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

SYMBOL  IsUp            = 1
SYMBOL  IsDown          = 0

SYMBOL  IsOn            = 1
SYMBOL  IsOff           = 0

SYMBOL  Baud            = OT2400


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

SYMBOL  relays          = B0
SYMBOL   Arm            =  BIT3                 ' RC-4 K4

SYMBOL  timer           = B2
SYMBOL  jumps           = B3

SYMBOL  delay           = W4
SYMBOL  lottery         = W5


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

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

  relays = IsOff
  GOSUB Update_RC4

  PAUSE 30000                                   ' pir warm-up / 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

  jumps = lottery // 3 + 3                      ' 3 to 5 jumps

Get_Jumpy:
  Arm = IsUp
  GOSUB Update_RC4
  PAUSE 50
  Arm = IsDown
  GOSUB Update_RC4
  RANDOM lottery
  delay = lottery // 2001 + 500                 ' 0.5 to 2.5s
  PAUSE delay
  jumps = jumps - 1
  IF jumps > 0 THEN Get_Jumpy

  GOTO Reset


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

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

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


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

JonnyMac

September 25, 2010, 10:37:50 AM #1 Last Edit: September 25, 2010, 10:43:15 AM by JonnyMac
QuoteThe art behind this was much harder than the creation of the code.

Especially when I write the code for you!!!  And, what, programmers aren't artists, too?!  ;D

All kidding aside, that's a great looking prop.  I wonder... could it be made even more life-like by using faster event timing?  Here's a different version of the code to try (if you like).  Instead of setting the number of jumps, it sets a window that the tail can jump.  It also randomizes both the on- and off-time values so that the tail doesn't always move full-swing in either direction -- we use this strategy in electric chair props and it works very well.

Note: Using the RC-4 adds 29ms to send a command -- this means that a 25ms delay in the program is 54ms in real time.  For this kind of prop it's not a problem, for others (e.g., sync'd with audio) you sometimes have to account for this.


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


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


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


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

SYMBOL  Sio             = 7                     ' SETUP = UP; no ULN
SYMBOL  Trigger         = PIN6                  ' SETUP = DN


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

SYMBOL  IsUp            = 1
SYMBOL  IsDown          = 0

SYMBOL  IsOn            = 1
SYMBOL  IsOff           = 0

SYMBOL  Baud            = OT2400


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

SYMBOL  relays          = B0
SYMBOL   Arm            =  BIT3                 ' RC-4 K4

SYMBOL  delay           = W3
SYMBOL  timer           = W4
SYMBOL  lottery         = W5


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

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

 relays = IsOff                                ' all off
 GOSUB Update_RC4

 PAUSE 30000                                   ' pir warm-up / 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

  timer = lottery // 5001 + 5000                ' jump ~5 to ~10 seconds

Get_Jumpy:
  RANDOM lottery
  delay = lottery // 76 + 25                    ' 25 to 100ms on
  IF delay > timer THEN Reset                   ' out of time
    Arm = IsUp
    GOSUB Update_RC4
    PAUSE delay
    timer = timer - delay                       ' update run-timer

  RANDOM lottery
  delay = lottery // 751 + 250                  ' 250 to 1000ms off
  IF delay > timer THEN Reset                   ' out of time
    Arm = IsDown
    GOSUB Update_RC4
    PAUSE delay
    timer = timer - delay                       ' update run-timer

  GOTO Get_Jumpy


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

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

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


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


Jon McPhalen
EFX-TEK Hollywood Office

vista

It depends if I get a chance to get back under the case again before the season is over if so I'll post a new video... I never meant to say programmers aren't artists just that my wife worked for days and really a week or more where as the code was fairly simple for you to write (And if it takes you more than 30 minutes I apologize but I'm betting you dream in code)  and all I had to do was envision the arm and build a box.. Credit goes in the order of my wife (did you have any doubts on that).. Then you, Jon and lastly me because any chimp could put all that together...  Now dammit where is my banana...!!!
With out you two I wouldn't have been able to create it...

Vista (is that my prop 1 smoking?)