November 22, 2024, 06:38:55 AM

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.


I need help programming the Prop-2

Started by Ryanm0085, September 20, 2008, 03:29:13 PM

Previous topic - Next topic

Ryanm0085

my names ryan.  i had spoke with someone a month ago about programming the prop 2.  I am using this at my firehouse for our haunted walk, but have never used basic before, or really any other programming code.  the person i had spoken with said i could email the scenerio to you and you would be able to write a script.  it is pretty long but i would appreciate the help.  i have not purchased the dimmer card for it yet, but plan on it so i added it in the script anyway.

           The scene i am using this for is for an old movie theater.  the theater has lights in the audience, and lights behind the curtain(Red).  the curtain is opened and closed by a garage door opener. i have connected a relay to a dvd player for player and to a projector to turn it on and off.  behind the curtain i have made an animatronic skeleton with pistons controlled with solenoids which are connected to the prop 2. 

           I can connect the wires any way.  i have not hooked anything up yet. i want the sequence to start when i push a button. 

           Before the scene starts, the theater lights should be fully lit.  The projector will be on and the dvd player will be in pause.  when the button is pushed, the theater lights should fade out and the dvd player should play(just a quick pulse to the relay.)  After the movie is done, about 1 minute, the red lights behind the curtain should fade in to full.  Once the lights are full, the projector will turn off(once again a pulse to a remote control) and the curtain will open(another pulse to the garage door opener) The animatronic is a skeleton with 7 pistons to move him.  he has 2 per arm(one for shoulder, and one for elbow) and 2 for left and right neck movement and one to tilt his head.  i figured u could just write a script using random movents, this way i could just go back into the script and adjust the movements exactly how i want them.  he will move for about 1 mintue, than the curtain will close(pulse), the lights in the theater will fade in and the red lights behind will fade out. after about 30 sec, the projector should turn back on(another pulse) and the dvd player should play, then after 1 sec, pause. (pulse, 1 sec wait, pulse)This is where it will wait for the next push of the button to redo the cycle.  The skeleton has red led eyes in his head.  if possible, id like to tie them on channel 10 to make them blink realisticly, but i wasnt sure if that would be possible without actually scripting each eye blink.  if that is the only way to do it, then i will take it out. 

I figured this is how i would hook it up.....

0 - Projector                                    Dimmer Channel 1- Theater Lights
1 - DVD Player                                Dimmer Channel 2 - Red Lights (behind curtain)
2 - Curtain
3 - Left Shoulder
4 - Left Elbow
5 - Right Shoulder
6 - Right Elbow
7 - Head Left
8 - Head Right
9 - Head tilt
10 - Eyes

I'd really appreciate any help you can offer me.  unfortunately i am running out of time for our haunted walk so i cannot take the time to read up on Basic.  I am better at learning by watching.  So i'm hoping by you writing the script to how i want to to work, i will be able to understand the coding better.  If you have an questions or sugestions please call me

JonnyMac

Jon McPhalen
EFX-TEK Hollywood Office

Ryanm0085


JonnyMac

September 22, 2008, 02:01:44 PM #3 Last Edit: October 11, 2008, 11:11:19 PM by JonnyMac
Okay, since I'm an honest guy, let me be honest: this is not a program I'm crazy about.  Why?  Because it seems like you're trying to take a show that is run by humans an automate it.  The problem?  Using pulse-on/pulse-off control is fine when a human is doing the pulsing because we have a feedback mechanism (our eyes) -- the controller doesn't.  So... you may have to do a lot of tweaking to this program to get it to work correctly; there is no possible way for me to test it on my bench.

On the skeleton motion: I've put this into a little sequencer engine where each step runs 1/10 of a second (you can change this, but 1/10th is easy to work with).  A "1" in the table for an output will turn it on.  Note that the eyes are also in this table so you will have to script them manually.

Code Updated: 11 OCT 2008

' =========================================================================
'
'   File...... Ryans_Theater.BS2
'   Purpose...
'   Author.... Jon Williams, EFX-TEK
'              Copyright (c) 2007 EFX-TEK
'   E-mail.... jwilliams@efx-tek.com
'   Started...
'   Updated... 11 OCT 2008
'
'   {$STAMP BS2}
'   {$PBASIC 2.5}
'
' =========================================================================


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


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


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

Sio             PIN     15                      ' SETUP = out; no ULN
Trigger         PIN     14                      ' SETUP = DN

Projector       PIN     10
DVD             PIN     9
Curtain         PIN     8

Eyes            PIN     7
ShoulderLf      PIN     6
ElbowLeft       PIN     5
ShoulderRt      PIN     4
ElbowRt         PIN     3
HeadLeft        PIN     2
HeadRt          PIN     1
HeadTilt        PIN     0


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

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


#SELECT $STAMP
  #CASE BS2, BS2E, BS2PE
    T2400       CON     396
    T38K4       CON     6
  #CASE BS2SX, BS2P
    T2400       CON     1021
    T38K4       CON     45
  #CASE BS2PX
    T2400       CON     1646
    T38K4       CON     84
#ENDSELECT

Open            CON     $8000
Baud            CON     Open + T38K4            ' baud jumper installed


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

timer           VAR     Byte

ch1             VAR     Byte                    ' theatre lights
ch2             VAR     Byte                    ' red lights
ch3             VAR     Byte                    ' channel 3
ch4             VAR     Byte                    ' channel 4

lottery         VAR     Word                    ' random value
record          VAR     Word
pntr            VAR     Word

noSleep         VAR     Word                    ' prevent DVD sleep


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

Reset:
  OUTH = %00000000 : OUTL = %00000000           ' clear all
  DIRH = %00000111 : DIRL = %11111111           ' P0-P10 are outputs

  ch1 = 255
  ch2 = 0
  ch3 = 0
  ch4 = 0
  GOSUB Set_FC4
  GOSUB Projector_On
  GOSUB DVD_Pause


' -----[ Program Code ]----------------------------------------------------
Main:
  timer = 0
  DO WHILE (timer < 100)                        ' wait for 0.1s input
    RANDOM lottery                              ' stir random value
    PAUSE 5
    timer = timer + 5 * Trigger
    noSleep = noSleep + 5
    IF (timer < 100) THEN                       ' don't bother if triggered
      IF (noSleep = 24000) THEN                 ' if 2 minutes
        GOSUB DVD_Pause                         ' prevent DVD sleep
        noSleep = 0                             ' reset timer
      ENDIF
    ENDIF
  LOOP

  ' fade out theater lights
  SEROUT Sio, Baud, ["!FC4", %00, "F", 1, 255, 0, 4]
  PAUSE 1000

  GOSUB DVD_Run
  PAUSE 60000

  ' fade up red lights
  SEROUT Sio, Baud, ["!FC4", %00, "F", 2, 0, 255, 4]
  PAUSE 1000

  GOSUB Projector_Off
  GOSUB Curtain_Open

Skeleton_Show:
  record = 0
  DO
    pntr = record * 2
    READ Show + pntr, OUTL, timer
    IF timer = 0 THEN
      EXIT
    ELSE
      DO WHILE (timer > 0)
        PAUSE 100
        timer = timer - 1
      LOOP
    ENDIF
    record = record + 1
  LOOP

  GOSUB Curtain_Close

  ' 15 second fade, red to threatre
  SEROUT Sio, Baud, ["!FC4", %00, "C", 0, 2, 1, 59]
  PAUSE 30000

  GOSUB Projector_On
  GOSUB DVD_Run
  PAUSE 1000
  GOSUB DVD_Pause

  GOTO Main


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

Set_FC4:
  SEROUT Sio, Baud, ["!FC4", %00, "S", ch1, ch2, ch3, ch4]
  RETURN

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

Projector_On:
  Projector = IsOn
  PAUSE 100
  Projector = IsOff
  RETURN

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

Projector_Off:
  Projector = IsOn
  PAUSE 100
  Projector = IsOff
  RETURN

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

DVD_Run:
  DVD = IsOn
  PAUSE 100
  DVD = IsOff
  RETURN

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

DVD_Pause:
  DVD = IsOn
  PAUSE 100
  DVD = IsOff
  RETURN

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

Curtain_Open:
  Curtain = IsOn
  PAUSE 100
  Curtain = IsOff
  RETURN

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

Curtain_Close:
  Curtain = IsOn
  PAUSE 100
  Curtain = IsOff
  RETURN

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

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

' Show data from bits on OUTL (P0-P7); timing is in 100ms units -- set
' time to zero to indicate end of show.
'
'                +------------- Eyes
'                |+------------ Shoulder Left
'                ||+----------- Elbow Left
'                |||+---------- Shoulder Right
'                ||||+--------- Elbow Right
'                |||||+-------- Head Left
'                ||||||+------- Head Right
'                |||||||+------ Head Tilt
'                ||||||||
Show    DATA    %00000001, 20                    ' 2.0 seconds
        DATA    %00000010, 20
        DATA    %00000100, 20
        DATA    %00001000, 20
        DATA    %00010000, 20
        DATA    %00100000, 20
        DATA    %01000000, 20
        DATA    %10000000, 20
        DATA    %00000000, 20
Jon McPhalen
EFX-TEK Hollywood Office

Ryanm0085

hey thanks for the help.  like i said this is the first time using this Prop-2.  i hooked everything up the way i thought but i'm not getting anything.  I have no clue where to hook up the fc-4 or even a clue on the trigger or any of the settings.  PLEASE HELP!!!!  I have a week before our haunted walk starts and must figure this out......Thanks Again

JonnyMac

October 01, 2008, 09:28:25 AM #5 Last Edit: October 01, 2008, 09:30:15 AM by JonnyMac
Okay, first things first... have you downloaded our docs for the products you're using?

-- http://www.efx-tek.com/downloads/prop-2_docs.pdf
-- http://www.efx-tek.com/downloads/fc-4_docs.pdf

On page 4 of the Prop-2 docs it will show you how to connect your trigger input button to P14 and the values/relays connected to the OUTx terminals.  For valves and relays, one side will connect to V+ (common), the other side to the associated OUTx terminal.  For example, the head tilt solenoid will connect between V+ and OUT0.

For the FC-4 you will want to set its configuration jumpers for 38.4K baud (B/R jumper installed) and address %00 (A0 and A1 jumpers removed).  An important step when using one of our serial accessories (FC-4, RC-4, AP-8, DC-16) is that you must remove the ULN2x03 influence from the serial control pin.  In your project you will replace the ULN2803 that serves P8..P15 with a ULN2003 -- or you can clip off pin 1 of the ULN2803 if you don't have the other chip (it comes with our starter kit).

This thread goes into details on that topic:

-- http://www.efx-tek.com/php/smf/index.php?topic=130.0

Once you've done that and connected the FC-4 via a 3-pin cable (make sure you have to polarity correct) you should see things happening.  I just dragged out my FC-4 tester board with four lamps and connected it; everything seems to be working properly.  That said, I slowed the pulsing and [test] valve outputs down so you could see them.  Grab the updated listing (above) and give it a try.
Jon McPhalen
EFX-TEK Hollywood Office

Ryanm0085

Hey Jon.  The program worked great but here is the problem.  I connected 4-75 watt lights on channel 1 with a total of 300 watts and the channel, i'm guessing, blew out.  i lost all control.  Then i took and hooked up 3-75 watt bulbs to channel 2, 225 watts, and the same thing happend.  Finally i hooked up 2-75 watt bulbs to channel 3 and it seems to work.  I dont understand since the specs say each channel will handle 300 watts each.  I need atleast 3 channels and i only have 2 operational channels now.  I NEED HELP.  Either i have to fix this one or i need a replacement.  I only followed the directions on the hook up.  Other than this, i am really starting to understand the program.  Please help.  I need this figured out and working by thursday.  Thanks....Ryan

JonnyMac

Ryan,

You're going to have to send your board to our Rocklin office for repair or purchase a replacement.  I suspect that your load is greater than 300 watts because we actually oversize all components and our spec is somewhat conservative.
Jon McPhalen
EFX-TEK Hollywood Office

Ryanm0085

i have purchased a replacement FC-4.  I checked my wattage on my light bulbs again and all four of them are 75 watts each.  Could i have done something wrong?  I don't want to get the new board and the same thing happen.  I am very excited for all of this to come together.  I went from not knowing a thing about basic to really starting to understand it.  I really appreciate the time you have spent with me to help me out.  If you have any suggestions so i don't blow the new FC-4 out please let me know.  Thanks Again!!!!!!!

JonnyMac

October 05, 2008, 10:52:08 PM #9 Last Edit: October 05, 2008, 10:55:37 PM by JonnyMac
Start with one light at a time.  It's a bit hard to tell what's happening since we can't see or know your wiring. Perhaps we should adjust the program so that it doesn't hard-start at the beginning (this will help deal with the initial load).

Try this new Reset section:

Reset:
  OUTH = %00000000 : OUTL = %00000000           ' clear all
  DIRH = %00000111 : DIRL = %11111111           ' P0-P10 are outputs

  SEROUT Sio, Baud, ["!!!!!!FC4", %00, "X"]
  SEROUT Sio, Baud, ["!FC4", %00, "F", 1, 0, 255, 1]
  GOSUB Projector_On
  GOSUB DVD_Pause
Jon McPhalen
EFX-TEK Hollywood Office

Ryanm0085

I have ran the sequence for 2 nights now and everything is working great!!! Thanks for all the help...  I do have one last question though, unfortunately i cannot just let the scene run by itself.  The DVD Player goes in sleep mode after 5 minutes or so.  So i have to keep hitting the stop button inbetween scenes becuase sometimes the groups come in shorter than 5 minutes or longer than 5 minutes.  Is there a way to set an output to keep hitting stop every 2 or 3 minutes while waiting for the trigger, but it would have to stop after the trigger was hit then start again once the sequence returns to main?

JonnyMac

Have a look at the updated listing.  I added a secondary timer to the Main loop that is controlled by "noSleep."  If this variable hits 24000 (two minutes) it will do something and then reset itself -- you'll probably have to adjust the listing for your output.
Jon McPhalen
EFX-TEK Hollywood Office