November 22, 2024, 02:16:04 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.


need program codes

Started by norm, October 15, 2007, 09:15:08 PM

Previous topic - Next topic

norm

I have 4 props that I am converting from electro-mechanical control
> to your Prop-1 Controller. I have been using  PIR sensors, delay
> timers, relay holding circuits etc.  for several years. However I am
> limited to what I can do with relays and timers, I need to start
> using a micro-controller.

> Here is a summary of my props sequence of operation: I would like to
> add the following in ( )

> Coffin:
> PIR sensor trips, (fog machine, on 5 sec.), coffin lid opens via
> pneumatics for 5 sec.and strobe light, after 2 sec. delay, corpus
> pops up via pneumatics, after initial 5 sec. everything closes and
> shuts off. wait 120 sec. to repeat cycle.

> Sarcophagus:
> PIR sensor trips, sarcophagus lid opens  via pneumatics for 6 sec.
> and strobe light, after 3 sec. mummy pops out via pneumatics, after
> initial 5 sec. everything closes and shuts off. wait 120 sec. to
> repeat cycle.

> Electric Chair:
> PIR sensor trips, flashing light on 5 sec., after 2 second delay
> body in electric chair moves back and forth very rapidly via
> pneumatics, I have double acting cylinders connect between the
> shoulder's and arms operated by a 5-way valve. I only need to signal
> the SPDT relay on and off in 1 second intervals. ( I would like to
> be able to change the rate of the intervals during the total cycle)
>  after initial 5 sec. everything shuts off. wait 120 sec. to repeat cycle.

> New prop for this year
> Stand up Coffin:
> PIR trips, sound starts and strobe light, after 2 sec. delay coffin
> door lowers via pneumatics for 5 sec. after door is down, I need to
> find out time. scary head pops up via pneumatics, after initial 5
> sec. everything closes and shuts off. wait 120 sec. to repeat cycle.

> I would appreciate if you can lay out the programming codes for the
> above props. I would like each device to have it's own output.

> Also I use a main control panel the has everything, air supply,
>  regulators, valves relays etc. I need to know what is the maximum
> distance I can locate your  PIR sensor from the Prop-1 controllers
> via the 3-pin cable.

Thanks
Norm  :)

JonnyMac

October 15, 2007, 09:24:57 PM #1 Last Edit: October 16, 2007, 12:32:15 AM by JonnyMac
In the future... would you please post these in separate threads with a title that describes each prop -- that will make search (by others) a whole lot easier.  This is noted in our "Forum Guidelines" post.
Jon McPhalen
EFX-TEK Hollywood Office

JonnyMac

October 15, 2007, 11:49:07 PM #2 Last Edit: October 15, 2007, 11:52:00 PM by JonnyMac
' =========================================================================
'
'   File...... Norm_Coffin.BS1
'   Purpose...
'   Author.... Jon Williams, EFX-TEK
'   E-mail.... jwilliams@efx-tek.com
'   Started...
'   Updated...
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


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

' Coffin:
' PIR sensor trips, (fog machine, on 5 sec.), coffin lid opens via
' pneumatics for 5 sec. and strobe light, after 2 sec. delay, corpus
' pops up via pneumatics, after initial 5 sec. everything closes and
' shuts off. wait 120 sec. to repeat cycle.


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


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

SYMBOL  PIR             = PIN6                  ' SETUP = DN
SYMBOL  Corpse          = PIN3                  ' valve to V+/OUT3
SYMBOL  Strobe          = PIN2                  ' relay to V+/OUT2
SYMBOL  Lid             = PIN1                  ' valve to V+/OUT1
SYMBOL  Fogger          = PIN0                  ' relay to V+/OUT0


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

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

SYMBOL  IsOpen          = 1
SYMBOL  IsClosed        = 0

SYMBOL  IsUp            = 1
SYMBOL  IsDown          = 0


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

SYMBOL  timer           = B2                    ' for PIR debounce


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

Reset:
  PINS = %00000000                              ' clear outputs
  DIRS = %00001111                              ' set output pins (P0..P3)

  PAUSE 20000                                   ' warm-up/inter-show delay
  timer = 0                                     ' clear for PIR debounce


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

Main:
  PAUSE 10
  timer = timer + 10 * PIR                      ' advance/clear timer
  IF timer < 250 THEN Main                      ' wait for valid signal

  Fogger = IsOn
  PAUSE 5000
  Fogger = IsOff

  Lid = IsOpen
  Strobe = IsOn
  PAUSE 2000                                    ' let lid open

  Corpse = IsUp
  PAUSE 3000

  Corpse = IsDown
  Strobe = IsOff
  PAUSE 1000                                    ' let corpse retract

  Lid = IsClosed


Long_Delay:
  PAUSE 60000                                   ' one minute
  PAUSE 40000                                   ' forty seconds

  GOTO Reset


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


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


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

JonnyMac

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


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

' Sarcophagus:
' PIR sensor trips, sarcophagus lid opens  via pneumatics for 6 sec.
' and strobe light, after 3 sec. mummy pops out via pneumatics, after
' initial 5 sec. everything closes and shuts off. wait 120 sec. to
' repeat cycle.


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


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

SYMBOL  PIR             = PIN6                  ' SETUP = DN
SYMBOL  Mummy           = PIN2                  ' valve to V+/OUT3
SYMBOL  Strobe          = PIN1                  ' relay to V+/OUT2
SYMBOL  Lid             = PIN0                  ' valve to V+/OUT1


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

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

SYMBOL  IsOpen          = 1
SYMBOL  IsClosed        = 0

SYMBOL  IsUp            = 1
SYMBOL  IsDown          = 0


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

SYMBOL  timer           = B2                    ' for PIR debounce


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

Reset:
  PINS = %00000000                              ' clear outputs
  DIRS = %00000111                              ' set output pins (P0..P2)

  PAUSE 20000                                   ' warm-up/inter-show delay
  timer = 0                                     ' clear for PIR debounce


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

Main:
  PAUSE 10
  timer = timer + 10 * PIR                      ' advance/clear timer
  IF timer < 250 THEN Main                      ' wait for valid signal

  Lid = IsOpen
  Strobe = IsOn
  PAUSE 3000                                    ' let lid open

  Mummy = IsUp
  PAUSE 2000

  Mummy = IsDown
  Strobe = IsOff
  PAUSE 1000                                    ' let corpse retract

  Lid = IsClosed


Long_Delay:
  PAUSE 60000                                   ' one minute
  PAUSE 40000                                   ' forty seconds

  GOTO Reset


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


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


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

JonnyMac

Warning: This program is not as simple as the others and will take some study to understand.  I changed the flash rate of the light to 2 Hz (every 500 ms) and extended the "electrocution" to five seconds of shaking (total active cycle is seven seconds).

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


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

' Electric Chair:
' PIR sensor trips, flashing light on 5 sec., after 2 second delay
' body in electric chair moves back and forth very rapidly via
' pneumatics, I have double acting cylinders connect between the
' shoulder's and arms operated by a 5-way valve. I only need to signal
' the SPDT relay on and off in 1 second intervals. ( I would like to
' be able to change the rate of the intervals during the total cycle)
' after initial 5 sec. everything shuts off. wait 120 sec. to repeat cycle.


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


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

SYMBOL  PIR             = PIN6                  ' SETUP = DN
SYMBOL  Body            = PIN1                  ' valve to V+/OUT1
SYMBOL  Light           = PIN0                  ' relay to V+/OUT0


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

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

SYMBOL  IsOpen          = 1
SYMBOL  IsClosed        = 0

SYMBOL  IsUp            = 1
SYMBOL  IsDown          = 0

SYMBOL  LightDelay      = 500                   ' change every 500 ms


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

SYMBOL  idx             = B2                    ' loop control
SYMBOL  flashTm         = W3                    ' light flash timer
SYMBOL  timer           = W4                    ' for PIR debounce/timing
SYMBOL  lottery         = W5                    ' random number


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

Reset:
  PINS = %00000000                              ' clear outputs
  DIRS = %00000011                              ' set output pins (P0..P1)

  PAUSE 20000                                   ' warm-up/inter-show delay
  timer = 0                                     ' clear for PIR debounce


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

Main:
  RANDOM lottery                                ' stir random number
  PAUSE 10
  timer = timer + 10 * PIR                      ' advance/clear timer
  IF timer < 250 THEN Main                      ' wait for valid signal


  timer = 0
  flashTm = 0

Flasher:
  Light = Light ^ 1                             ' flip light output

Flash_Hold:
  PAUSE 50
  timer = timer + 50
  IF timer >= 2000 THEN Shock_Me
  flashTm = flashTm + 50
  IF flashTm < LightDelay THEN Flash_Hold
    flashTm = 0
    GOTO Flasher


Shock_Me:
  timer = 0
  flashTm = 0

Dr_Shocker:                                     ' aka Dan Roebuck!
  RANDOM lottery
  Body = lottery
  PAUSE 50

Check_Light_Timer:
  flashTm = flashTm + 50
  IF flashTm < LightDelay THEN Check_Shock_Timer
    Light = Light ^ 1
    flashTm = 0

Check_Shock_Timer:
  timer = timer + 50
  IF timer < 5000 THEN Dr_Shocker
    PINS = %00000000                            ' clear outputs


Long_Delay:
  PAUSE 60000                                   ' one minute
  PAUSE 40000                                   ' forty seconds

  GOTO Reset


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


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


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

JonnyMac

I'm not the sharpest tool in the shed so I find your description for this one very confusing -- you'll probably have to make adjustments.

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


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

' Stand up Coffin:
' PIR trips, sound starts and strobe light, after 2 sec. delay coffin
' door lowers via pneumatics for 5 sec. after door is down, I need to
' find out time. scary head pops up via pneumatics, after initial 5
' sec. everything closes and shuts off. wait 120 sec. to repeat cycle.


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


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

SYMBOL  Sio             = 7                     ' SETUP = out; no ULN
SYMBOL  PIR             = PIN6                  ' SETUP = DN
SYMBOL  Head            = PIN2                  ' valve to V+/OUT2
SYMBOL  Door            = PIN1                  ' valve to V+/OUT1
SYMBOL  Strobe          = PIN0                  ' relay to V+/OUT0


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

SYMBOL  Baud            = OT2400                ' for EFX-TEK boards

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

SYMBOL  IsOpen          = 1
SYMBOL  IsClosed        = 0

SYMBOL  IsUp            = 1
SYMBOL  IsDown          = 0



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

SYMBOL  idx             = B2                    ' loop control
SYMBOL  flashTm         = W3                    ' light flash timer
SYMBOL  timer           = W4                    ' for PIR debounce/timing
SYMBOL  lottery         = W5                    ' random number


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

Reset:
  PINS = %00000000                              ' clear outputs
  DIRS = %00000011                              ' set output pins (P0..P1)

  SEROUT Sio, Baud, ("!!!!!!!AP8", %00, "X")    ' kill sound on reset

  PAUSE 20000                                   ' warm-up/inter-show delay
  timer = 0                                     ' clear for PIR debounce


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

Main:
  RANDOM lottery                                ' stir random number
  PAUSE 10
  timer = timer + 10 * PIR                      ' advance/clear timer
  IF timer < 250 THEN Main                      ' wait for valid signal

Start_Audio:
  SEROUT Sio, Baud, ("!AP8", %00, "P", 0)

  Strobe = IsOn
  PAUSE 2000

  Door = IsOpen
  PAUSE 5000

  Head = IsUp
  PAUSE 1000

  Strobe = IsOff
  Head = IsDown
  PAUSE 500

  Door = IsClosed

Long_Delay:
  PAUSE 60000                                   ' one minute
  PAUSE 40000                                   ' forty seconds

  GOTO Reset


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


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


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

norm

Jon,
The program works great. However what I would like is the flashing light to start first,  after a 2 sec. delay then the body would start in a randon
motion (just like your first program code), after 6 seconds everything shuts down.

Thanks
Norm


Quote from: JonnyMac on October 16, 2007, 12:31:24 AM
Warning: This program is not as simple as the others and will take some study to understand.  I changed the flash rate of the light to 2 Hz (every 500 ms) and extended the "electrocution" to five seconds of shaking (total active cycle is seven seconds).

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


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

' Electric Chair:
' PIR sensor trips, flashing light on 5 sec., after 2 second delay
' body in electric chair moves back and forth very rapidly via
' pneumatics, I have double acting cylinders connect between the
' shoulder's and arms operated by a 5-way valve. I only need to signal
' the SPDT relay on and off in 1 second intervals. ( I would like to
' be able to change the rate of the intervals during the total cycle)
' after initial 5 sec. everything shuts off. wait 120 sec. to repeat cycle.


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


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

SYMBOL  PIR             = PIN6                  ' SETUP = DN
SYMBOL  Body            = PIN1                  ' valve to V+/OUT1
SYMBOL  Light           = PIN0                  ' relay to V+/OUT0


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

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

SYMBOL  IsOpen          = 1
SYMBOL  IsClosed        = 0

SYMBOL  IsUp            = 1
SYMBOL  IsDown          = 0

SYMBOL  LightDelay      = 500                   ' change every 500 ms


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

SYMBOL  idx             = B2                    ' loop control
SYMBOL  flashTm         = W3                    ' light flash timer
SYMBOL  timer           = W4                    ' for PIR debounce/timing
SYMBOL  lottery         = W5                    ' random number


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

Reset:
  PINS = %00000000                              ' clear outputs
  DIRS = %00000011                              ' set output pins (P0..P1)

  PAUSE 20000                                   ' warm-up/inter-show delay
  timer = 0                                     ' clear for PIR debounce


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

Main:
  RANDOM lottery                                ' stir random number
  PAUSE 10
  timer = timer + 10 * PIR                      ' advance/clear timer
  IF timer < 250 THEN Main                      ' wait for valid signal


  timer = 0
  flashTm = 0

Flasher:
  Light = Light ^ 1                             ' flip light output

Flash_Hold:
  PAUSE 50
  timer = timer + 50
  IF timer >= 2000 THEN Shock_Me
  flashTm = flashTm + 50
  IF flashTm < LightDelay THEN Flash_Hold
    flashTm = 0
    GOTO Flasher


Shock_Me:
  timer = 0
  flashTm = 0

Dr_Shocker:                                     ' aka Dan Roebuck!
  RANDOM lottery
  Body = lottery
  PAUSE 50

Check_Light_Timer:
  flashTm = flashTm + 50
  IF flashTm < LightDelay THEN Check_Shock_Timer
    Light = Light ^ 1
    flashTm = 0

Check_Shock_Timer:
  timer = timer + 50
  IF timer < 5000 THEN Dr_Shocker
    PINS = %00000000                            ' clear outputs


Long_Delay:
  PAUSE 60000                                   ' one minute
  PAUSE 40000                                   ' forty seconds

  GOTO Reset


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


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


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


JonnyMac

October 29, 2007, 09:42:56 PM #7 Last Edit: October 30, 2007, 07:45:58 AM by JonnyMac
Okay... turns out I may have over-thought the first version.  What follows is:

* wait on PIR
* start flashing light
* after two seconds thrash body (while light continues to flash)
* after four seconds (six since start of cycle) shut everything down

This version of the program is more elegant and makes setting the flash rate, the delay until body movement, and the overall cycle time much easier.  I'm sorry I didn't come up with this one the first time.

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


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

' Electric Chair:
' PIR sensor trips, flashing light on 6 sec., after 2 second delay
' body in electric chair moves back and forth very rapidly via
' pneumatics, I have double acting cylinders connect between the
' shoulder's and arms operated by a 5-way valve. I only need to signal
' the SPDT relay on and off in 1 second intervals. ( I would like to
' be able to change the rate of the intervals during the total cycle)
' after initial 6 sec. everything shuts off. wait 120 sec. to repeat cycle.


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


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

SYMBOL  PIR             = PIN6                  ' SETUP = DN
SYMBOL  Body            = PIN1                  ' valve to V+/OUT1
SYMBOL  Light           = PIN0                  ' relay to V+/OUT0


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

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


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

SYMBOL  flashTmr        = W3                    ' for flash cycle timing
SYMBOL  timer           = W4                    ' for PIR debounce/timing
SYMBOL  lottery         = W5                    ' random number


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

Reset:
  PINS = %00000000                              ' clear outputs
  DIRS = %00000011                              ' set output pins (P0..P1)

  PAUSE 20000                                   ' warm-up/inter-show delay
  timer = 0                                     ' clear for PIR debounce


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

Main:
  RANDOM lottery                                ' stir random number
  PAUSE 10
  timer = timer + 10 * PIR                      ' advance/clear timer
  IF timer < 250 THEN Main                      ' wait for valid signal

  timer = 0
  flashTmr = 0
  Light = IsOn

Flash_N_Shake:
  RANDOM lottery                                ' re-stir random number

Check_Light:
  IF flashTmr < 250 THEN Check_Body             ' 0.25 seconds?
    Light = Light ^ 1                           ' toggle light
    flashTmr = 0                                ' reset flash timer

Check_Body:
  IF timer < 2000 THEN Check_Timer              ' 2 seconds passed?
    Body = lottery                              ' yep, make body move

Check_Timer:
  PAUSE 50
  flashTmr = flashTmr + 50                      ' update flash timer
  timer = timer + 50                            ' update cycle timer
  IF timer < 6000 THEN Flash_N_Shake            ' run for 6 seconds?
    PINS = %00000000                            ' yes, clear outputs

Long_Delay:
  PAUSE 60000                                   ' one minute
  PAUSE 40000                                   ' forty seconds

  GOTO Reset


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


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


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

norm

Thanks Jon
I am using the old program for tonight but will use the new one for halloween night

Norm