November 23, 2024, 07:48:51 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.


program help

Started by ryagl, April 11, 2009, 05:43:36 PM

Previous topic - Next topic

ryagl

Hey guys I am having some serious problems programming my desired effect.  I emailed Jon and he request that I come on the forum and explain what effect I want to see if anyone would be willing to help out in writing a program.  Here is what equipment I have.  I have prop controller 1 with rc-4 for ac uses.  I am using a pir sensor.  My desired effect is a electrocution chair.  I am using a solenoid with pneumatic cylinder to active the prop.  I have a ap-8 for audio and a light and fog machine.  I want to have the ap-8 begin playing 5 seconds prior to the start of the animation and last 30 seconds long.  After 5 seconds of audio I want to have the solenoid begin to go on and off rapidly  for 15 seconds while the audio is still playing.  At the same time as the solenoid begins I want my fog machine to start and stop after 5 seconds.  At the same time I also want to have a light flicker on and off and turn off after 15 seconds.  After 20 seconds of complete program the audio will play for 10 more seconds and then end program.  The entire program will only last about 30 seconds.  My solenoid is tied into k1, fog machine into k2 and light into k3.  I have been working with this for about 4 months with no success.   I am just not grasping the programming.   I am not even sure if these are placed into the correct spots.  If there is anyone who would mind giving their patient time and help me to write this program I will greatly appreciate it more than you can imagine.  I will move anything that you tell me to.  I will move the lights etc into which ever port would be best.  I have seen the new ez-8 and fully intend to use this for my future projects.   Thank you in advance.

Desperate

Ryan

JonnyMac

That program is involved, but I can knock it out in about 10 minutes (comes with 15 years of practice on the BS1).  Just to be clear, though, are you using a 120 VAC solenoid? 
Jon McPhalen
EFX-TEK Hollywood Office

ryagl

Yes sir it is.

thank you

JonnyMac

Here you go.  Now... you're going to need to look at the instructions for using the RC-4 and AP-8 with the Prop-1.  Things you need to do:

1) Replace the ULN2803 with a ULN2003 (came with the starter kit) -- this allows serial on the P7 pin
    -- directions for the change are in the Prop-1 Trainer documentation
2) Move the P7 SETUP jumper to UP
3) Move the P6 SETUP jumper to DN (this is where you connect the PIR)
4) Connect the RC-4 to the Prop-1.P7, then the AP-8 to the RC-4 (use the serial headers on the RC-4 and AP-8)
5) Make sure that the RC-4 and AP-8 have the Baud, A0, and A1 jumpers removed.
   -- Prop-1.P7 --> RC-4.Serial --> AP-8.Serial

Here's the program:

' =========================================================================
'
'   File...... Ryan_Electric_Chair.BS1
'   Purpose...
'   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... 11 APR 2009
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


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


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


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

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


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

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

SYMBOL  Yes             = 1
SYMBOL  No              = 0


SYMBOL  Baud            = OT2400                ' B/R jumper removed


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

SYMBOL  relays          = B0
SYMBOL   Solenoid       =  BIT0                 ' on K1
SYMBOL   Fogger         =  BIT1                 ' on K2
SYMBOL   Light          =  BIT2                 ' on K3
SYMBOL   K4             =  BIT3

SYMBOL  idx             = B1                    ' loop controller
SYMBOL  sfx             = B2                    ' sound segment

SYMBOL  timer           = W4
SYMBOL  lottery         = W5                    ' random #


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

Reset:
  PINS = %00000000                              ' clear all
  DIRS = %00000000                              ' no outputs

  PAUSE 250                                     ' let AP-8 power up
  GOSUB Kill_Audio                              ' stop AP-8
  relays = %0000
  GOSUB Set_Relays                              ' clear relays


' -----[ 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

Start_Audio:
  sfx = 0                                       ' play segment 0
  GOSUB Play_Audio
  PAUSE 5000                                    ' wait 5 secs

  timer = 5000                                  ' set to 0:05 mark
  Fogger = IsOn

Shake_It:
  RANDOM lottery
  Solenoid = lottery                            ' randomize Solenoid
  RANDOM lottery
  Light = lottery                               ' randomize Light
  GOSUB Set_Relays
  PAUSE 69                                      ' 100 - 29
  timer = timer + 100                           ' update timer

Check_Fog:
  IF timer < 10000 THEN Shake_It
    Fogger = IsOff

Check_Chair:
  IF timer < 20000 THEN Shake_It
    relays = %0000                              ' all off
    GOSUB Set_Relays

Wait_Audio:
  PAUSE 30000                                   ' audio finish + loop delay
  GOTO Main


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

' Update RC-4 with "relays"
' -- takes 29ms @ 2400 baud

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

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

Kill_Audio:
  SEROUT Sio, Baud, ("!AP8", %00, "X")
  RETURN

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

Play_Audio:
  SEROUT Sio, Baud, ("!AP8", %00, "P", sfx)
  RETURN


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

ryagl

Just tried the program out and it works.  I cant thank you enough Jon.  My projected timing was off a little though.  I would like the light and solenoid to go off for an additional 5 seconds and as I have found out a little fog goes a long way.  I would like to cut it down to 1 second.  I tried to alter the program with the little knowledge that I have but the program did not seem to change.  What do I need to do?

thank you

JonnyMac

I'm glad it works -- it did on my desk!

Now... the term "go off" is confusing to me (remember, I'm an actor in my other life) so we need to find a better way to specify timing.  I have used the values in timer to correspond to the actual time after activation, hence the prop is programmed like this:

Audio: start at T00.0 and ends around T30.0
Fog: start at T05.0 and ends around T10.0
Chair: start at T05.0 and ends at T20.0
Light: start at T05.0 and ends at T20.0

Note: T (time) xx.x indicates seconds (max is to 65) and fractions of seconds (if you want that), with a resolution of 0.1 seconds.

So... give the the start and end times for any changes and I'll update the program; once you see the update things will begin to make sense.
Jon McPhalen
EFX-TEK Hollywood Office

ryagl

Audio: start at T00.0 and end T30.0
Fog machine: Start T10.0 end T12.0
Chair: start T05.0 and end at T25.0
Light: start T05.0 and end at T25.0

I think that this will make everything right.  Again thank you for taking your time to help. 

Ryan

JonnyMac

Here you go.  Note that the timing checks are always in ascending order -- this lets the first check loop back to the top when the other checks would be false, anyway.

' =========================================================================
'
'   File...... Ryan_Electric_Chair.BS1
'   Purpose...
'   Author.... Jon Williams, EFX-TEK
'              Copyright (c) 2009 EFX-TEK
'              Some Rights Reserved
'              -- see http://creativecommons.org/licenses/by/3.0/
'   E-mail.... jwilliams@efx-tek.com
'   Started...
'   Updated... 17 APR 2009
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


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


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


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

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


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

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

SYMBOL  Yes             = 1
SYMBOL  No              = 0


SYMBOL  Baud            = OT2400                ' B/R jumper removed


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

SYMBOL  relays          = B0
SYMBOL   Solenoid       =  BIT0                 ' on K1
SYMBOL   Fogger         =  BIT1                 ' on K2
SYMBOL   Light          =  BIT2                 ' on K3
SYMBOL   K4             =  BIT3

SYMBOL  idx             = B1                    ' loop controller
SYMBOL  sfx             = B2                    ' sound segment

SYMBOL  timer           = W4
SYMBOL  lottery         = W5                    ' random #


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

Reset:
  PINS = %00000000                              ' clear all
  DIRS = %00000000                              ' no outputs

  PAUSE 250                                     ' let AP-8 power up
  GOSUB Kill_Audio                              ' stop AP-8
  relays = %0000
  GOSUB Set_Relays                              ' clear relays


' -----[ 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

Start_Audio:
  sfx = 0                                       ' play segment 0
  GOSUB Play_Audio
  PAUSE 5000                                    ' wait 5 secs

  timer = 5000                                  ' set to 0:05 mark

Shake_It:
  RANDOM lottery
  Solenoid = lottery                            ' randomize Solenoid
  RANDOM lottery
  Light = lottery                               ' randomize Light
  GOSUB Set_Relays
  PAUSE 69                                      ' 100 - 29
  timer = timer + 100                           ' update timer

Check_Fog_Start:
  IF timer < 10000 THEN Shake_It
    Fogger = IsOn

Check_Fog_Stop:
  IF timer < 12000 THEN Shake_It
    Fogger = IsOff

Check_Chair:
  IF timer < 25000 THEN Shake_It
    relays = %0000                              ' all off
    GOSUB Set_Relays

Wait_Audio:
  PAUSE 30000                                   ' audio finish + loop delay
  GOTO Main


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

' Update RC-4 with "relays"
' -- takes 29ms @ 2400 baud

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

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

Kill_Audio:
  SEROUT Sio, Baud, ("!AP8", %00, "X")
  RETURN

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

Play_Audio:
  SEROUT Sio, Baud, ("!AP8", %00, "P", sfx)
  RETURN


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

ryagl

That was it.  It runs perfect.  Thanks Jon you are not given enough appreciation by us on these forums. 

Thank you

Ryan

ryagl

Hey Jon I added another light to my program but I can't get it to turn on when I want it to.  I am using the same program that you wrote, but I am trying to add a flood light that turns on at the same time as the audio (ap-8) starts and turn off the same time that it ends.  I tried light2 = IsOn and IsOff at the beginning and the end of the program, but the light turns on at the same time as the other lights\solenoid.  I assigned Symbol Light2 to K4.  Here is what I did.   Can you help.

thank you


' =========================================================================
'
'   File...... Ryan_Electric_Chair.BS1
'   Purpose...
'   Author.... Jon Williams, EFX-TEK
'              Copyright (c) 2009 EFX-TEK
'              Some Rights Reserved
'              -- see http://creativecommons.org/licenses/by/3.0/
'   E-mail.... jwilliams@efx-tek.com
'   Started...
'   Updated... 17 APR 2009
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


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


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


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

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


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

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

SYMBOL  Yes             = 1
SYMBOL  No              = 0


SYMBOL  Baud            = OT2400                ' B/R jumper removed


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

SYMBOL  relays          = B0
SYMBOL   Solenoid       =  BIT0                 ' on K1
SYMBOL   Fogger         =  BIT1                 ' on K2
SYMBOL   Light          =  BIT2                 ' on K3
SYMBOL   Light2             =  BIT3           ' on K4

SYMBOL  idx             = B1                    ' loop controller
SYMBOL  sfx             = B2                    ' sound segment

SYMBOL  timer           = W4
SYMBOL  lottery         = W5                    ' random #


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

Reset:
  PINS = %00000000                              ' clear all
  DIRS = %00000000                              ' no outputs

  PAUSE 250                                     ' let AP-8 power up
  GOSUB Kill_Audio                              ' stop AP-8
  relays = %0000
  GOSUB Set_Relays                              ' clear relays


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

Main:
  timer = 0                                     ' reset timer

Light2 = IsOn

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

Start_Audio:
  sfx = 0                                       ' play segment 0
  GOSUB Play_Audio
  PAUSE 5000                                    ' wait 5 secs

  timer = 5000                                  ' set to 0:05 mark

Shake_It:
  RANDOM lottery
  Solenoid = lottery                            ' randomize Solenoid
  RANDOM lottery
  Light = lottery                               ' randomize Light
  GOSUB Set_Relays
  PAUSE 69                                      ' 100 - 29
  timer = timer + 100                           ' update timer

Check_Fog_Start:
  IF timer < 10000 THEN Shake_It
    Fogger = IsOn

Check_Fog_Stop:
  IF timer < 12000 THEN Shake_It
    Fogger = IsOff

Check_Chair:
  IF timer < 25000 THEN Shake_It
    relays = %0000                              ' all off
    GOSUB Set_Relays

Wait_Audio:
  PAUSE 30000                                   ' audio finish + loop delay

Light2 = IsOff

  GOTO Main


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

' Update RC-4 with "relays"
' -- takes 29ms @ 2400 baud

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

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

Kill_Audio:
  SEROUT Sio, Baud, ("!AP8", %00, "X")
  RETURN

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

Play_Audio:
  SEROUT Sio, Baud, ("!AP8", %00, "P", sfx)
  RETURN


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

livinlowe

May 21, 2009, 05:50:44 AM #10 Last Edit: May 21, 2009, 07:56:37 AM by livinlowe
Add a:
Gosub Set_Relays after your Light2=IsOn

Edit: You will have to add one to Light2=IsOff as well
Shawn
Scaring someone with a prop you built -- priceless!

JonnyMac

Shawn is correct: when you want to affect any of the outputs connected to the RC-4 you have to set the state (IsOn or IsOff) and then do a GOSUB Set_Relays.
Jon McPhalen
EFX-TEK Hollywood Office

ryagl

Thanks guys, I added it to the program and it works fine. 

Ryan