November 23, 2024, 10:24:27 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.


Help with coffin program please

Started by Rayneman, September 22, 2011, 05:20:02 PM

Previous topic - Next topic

Rayneman

Hi everyone,
I'm new to programming controllers and I'm hoping some one can help me out. I'm trying to program a prop 1 to run my coffin prop. The show is gonna be when people walk up to the coffin they will see a red light on in the coffin and then trip the PIR the red light will go out a strobe light will come on and a fog machine will start pumping out fog, and then one cylinder will activate randomly and violently causing the lid to move up and down, and with this a audio track will play. Once the prop has run its course the initial red light should come back on when everything else has ended. There is only the one pneumatic piston, 1 strobe, and 1 red light that will be controlled by a rc-4 board, the audio board will be a cowlalicous audio board. I think the whole thing should run for approx 30 sec, and the not be able to be triggered again for 30 sec's.
I just want to say thank you in advance for everyone's help.

JonnyMac

September 22, 2011, 07:18:07 PM #1 Last Edit: September 24, 2011, 10:43:32 AM by JonnyMac
This should get you started.

Updated 24 SEP

' =========================================================================
'
'   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
SYMBOL  Audio           = PIN5                  ' Cowlacious Audio
SYMBOL  Cylinder        = PIN0


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

SYMBOL  Yes             = 1
SYMBOL  No              = 0

SYMBOL  TrOn            = 1                     ' active-high trigger
SYMBOL  TrOff           = 0

SYMBOL  IsOn            = 1                     ' active-high I/O
SYMBOL  IsOff           = 0

SYMBOL  Baud            = OT2400

SYMBOL  ShowTime        = 30000                 ' duration of jumping
SYMBOL  FogTime         =  5000                 ' 5s blast of fog


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

SYMBOL  relays          = B0
SYMBOL   Light          =  BIT0                 ' K1
SYMBOL   Fogger         =  BIT1                 ' K2

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


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

Power_Up:
  PAUSE 100                                     ' * let RC-4 power up

Reset:
  PINS = %00000000                              ' all off
  DIRS = %00111111                              ' * set output pins

  Light = IsOn
  Fogger = IsOff
  GOSUB Update_RC4

  PAUSE 30000                                   ' 30s intershow delay


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

Main:
  timer = 0                                     ' reset debounce timer

Check_Trigger:
  RANDOM lottery                                ' stir random #
  PAUSE 5                                       ' scan delay
  IF Trigger = TrOff THEN Main                  ' check trigger input
    timer = timer + 5                           ' update timer
  IF timer < 200 THEN Check_Trigger             ' check timer

Lights_Out:
  Light = IsOff                                 ' kill light
  GOSUB Update_RC4
  PAUSE 5000                                    ' hold for suspense

Start_Audio:
  Audio = IsOn
  PAUSE 250
  Audio = IsOff

Run_Show:
  Fogger = IsOn                                 ' activate fogger
  GOSUB Update_RC4
  timer = 0                                     ' reset timer

Jump:
  Cylinder = IsOn - Cylinder                    ' toggle cylinder output
  RANDOM lottery
  delay = lottery // 151 + 100                  ' 100 to 250ms
  PAUSE delay
  timer = timer + delay                         ' update run timer
  IF timer < FogTime THEN Jump                  ' fogger still on?

Fog_Off:
  Fogger = IsOff                                ' no, off
  GOSUB Update_RC4                              ' *
  timer = timer + 29                            ' * account for message


  IF timer < ShowTime THEN Jump                 ' show still running?
    GOTO Reset                                  ' no, reset everything


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

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

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


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

Rayneman

Thanks so much for your help. I ran the program through the trainer but it only shows the random cylinder movement not the constant on light before the show happens, or the fogger or the strobe light coming on. Was wondering if that's the programming or if I messed up loading it on the controller.

JonnyMac

Did I miss something? I thought the light and the fogger were controlled by the RC-4 -- you can't see those things on the trainer, and you can't plug the RC-4 into the board when the trainer is in place. 
Jon McPhalen
EFX-TEK Hollywood Office

Rayneman

No you are correct after I ranthe trainer I then connected the the prop1 to the rc-4, you'll have to forgive me I'm new to the whole system you use but I thought the controller would send the signal to the rc-4 in order to trigger the other events, and to be honest I'm not entirely sure I connected the prop 1 to the rc- 4 correctly. But when I connected the two boards together I triggered the prop with the PIR and the indicator lights on the rc4 lit up for the piston and I assumed I would see the same thing for the other things that the rc4 is going to control.

JonnyMac

No worries, we all start "new" and even those of us that are "old" are human and suffer "gotchas."  Looking over your original program I found a couple.  In the listing above you'll find a couple lines marked with "*" -- these are lines I fixed.  This was a simple program and with a desk full of other projects I didn't test.  Today I did and found and fixed the gotchas.  Sorry....

I like programming because I can recreate at will.  The original program (above) uses a serial link to the RC-4.  Here's a different version that uses direct links from pins to the RC-4 X connectors (you'd need two of the 3-pin wires instead of one).  When you run this version on the trainer you'll see everything (remove the trainer and connect the RC-4 after).

Note: Both programs have a PIR warm-up/inter-show delay of 30s, so after you download the program you have to wait 30s before pressing the button on the trainer.

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


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


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


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

SYMBOL  Trigger         = PIN6                  ' SETUP = DN
SYMBOL  Audio           = PIN5                  ' Cowlacious Audio

SYMBOL  Fogger          = PIN2                  ' connect to RC-4.X2
SYMBOL  Light           = PIN1                  ' connect to RC-4.X1
SYMBOL  Cylinder        = PIN0


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

SYMBOL  Yes             = 1
SYMBOL  No              = 0

SYMBOL  TrOn            = 1                     ' active-high trigger
SYMBOL  TrOff           = 0

SYMBOL  IsOn            = 1                     ' active-high I/O
SYMBOL  IsOff           = 0

SYMBOL  ShowTime        = 30000                 ' duration of jumping
SYMBOL  FogTime         =  5000                 ' 5s blast of fog


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

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


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

Power_Up:
  ' put code here that only happens at power-up/hard reset

Reset:
  PINS = %00000000                              ' all off
  DIRS = %00111111                              ' set output pins

  Light = IsOn

  PAUSE 30000                                   ' 30s intershow delay


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

Main:
  timer = 0                                     ' reset debounce timer

Check_Trigger:
  RANDOM lottery                                ' stir random #
  PAUSE 5                                       ' scan delay
  IF Trigger = TrOff THEN Main                  ' check trigger input
    timer = timer + 5                           ' update timer
  IF timer < 200 THEN Check_Trigger             ' check timer

Lights_Out:
  Light = IsOff                                 ' kill light
  PAUSE 5000                                    ' hold for suspense

Start_Audio:
  Audio = IsOn
  PAUSE 250
  Audio = IsOff

Run_Show:
  Fogger = IsOn                                 ' activate fogger
  timer = 0                                     ' reset timer

Jump:
  Cylinder = IsOn - Cylinder                    ' toggle cylinder output
  RANDOM lottery
  delay = lottery // 151 + 100                  ' 100 to 250ms
  PAUSE delay
  timer = timer + delay                         ' update run timer
  IF timer < FogTime THEN Jump                  ' fogger still on?

Fog_Off:
  Fogger = IsOff                                ' no, off

  IF timer < ShowTime THEN Jump                 ' show still running?
    GOTO Reset                                  ' no, reset everything


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


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


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