November 23, 2024, 02:19:44 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.


Killer of controllers or Newbie... Your pick!

Started by vista, September 24, 2008, 08:23:27 PM

Previous topic - Next topic

vista

 ;D I talked to John today and I'm the one how didn't read the part about not connect AC direct to my prop 1... He told me to thank the gods that I didn't burn it out...
With his help I got on track a bit and cobbled together several programs to get my pneumatic arm to work with my PIR and my prop1 and RC4. What I'd like to know how much more I can do with the set up.
What my goal is, is to have the lid of a casket open a few times then on the final time it will stay open for 5-6 second and a second pneumatic arm will reach out a latex arm towards a Tot.

To top that off I would like there to be both a fog machine inside and a red floodlight and have them on while from the start of the lid opening to the final close...

If anyone cares to help someone who nearly fried their prop1, I would appreciate it. I have seen a couple of programs for the light and the fog machine but I have seen any code that meshes the PIR sensor starting the cascade of two pneumatic arms and then merge in the other items..
Right now I have 2 relays for the RC-4 and think I'm going to need 2 more or is there a  more efficient method..

Jeff


' Cobbled together from programs written by better people than I...
'
'
' this program will watch for the PIR sensor to trigger on PIN6, and then will fire
' two pneumatic arms and light a red flood and fill the box with fog from fog machine.
'
'
' {$STAMP BS1}
' {$PBASIC 1.0}
' SYMBOL PIR = PIN6 ' SETUP = DN (or out)
SYMBOL  Sio           = 7
SYMBOL  Baud          = OT2400

SYMBOL  No      = 0
'SYMBOL  MatSw   = PIN6

' -----[ I/O Definitions ]-------------------------------------------------
SYMBOL PIR = PIN6 ' SETUP = DN (or out)
' -----[ Constants ]-------------------------------------------------------
SYMBOL IsOn = 1 ' for active-high in/out
SYMBOL IsOff = 0
SYMBOL ScanDelay = 10 ' 10 ms scan delay
SYMBOL  id0             = B0                            ' version string
SYMBOL  id1             = B1
SYMBOL  id2             = B2

' -----[ Variables ]-------------------------------------------------------
SYMBOL pirTimer = B2 ' for debouncing




'Reset:
' DIRS = %00111111                  ' make P7-P6 inputs, P5-P0 outputs
' PINS = %00000000                  ' all outputs off
' -----[ Initialization ]--------------------------------------------------
Reset:
PAUSE 500 ' warm-up/inter-show delay
pirTimer = 0 ' clear timer for scan
' -----[ Program Code ]----------------------------------------------------
Main:
PAUSE ScanDelay
pirTimer = pirTimer + ScanDelay * PIR ' advance/clear timer
IF pirTimer < 250 THEN Main
' control code here

SEROUT Sio, OT2400, ("!RC4", %00, "V")
SERIN Sio, OT2400, id0, id1, id2
DEBUG "RC-4 Version ", #@id0, #@id1, #@id2, CR


SEROUT Sio, Baud, ("!RC4", %00, "R", 1, 1)     ' lift prop
  PAUSE 500                                    ' hold for 1/2 seconds
  SEROUT Sio, Baud, ("!RC4", %00, "R", 1, 0)    ' retract prop
  PAUSE 200                                    ' hold for 1/2 seconds
  SEROUT Sio, Baud, ("!RC4", %00, "R", 1, 1)     ' lift prop
  PAUSE 5000                                    ' hold for 1/2 seconds
  SEROUT Sio, Baud, ("!RC4", %00, "R", 1, 0)    ' retract prop
  PAUSE 5000                                  ' hold for 5 seconds
GOTO Reset                                     ' wait for next activation of sensor


' I want at this point to add a second command line that while the lid is open
' a second pneumatic arm will reach out of the box then pull back in and the
' lid will close.

' And if not to make it worse... I would like to have a fog machine and a
' red flood in the box also that run concurrently as the box opens and closes...

JonnyMac

September 25, 2008, 10:11:06 AM #1 Last Edit: September 25, 2008, 10:12:52 AM by JonnyMac
Actually, you spoke with Jon!   ;D

Give this program a try -- it's like most of my MiB programs using RANDOM to make the lid shaking a little more interesting.  You may have to tweak some timing values for your valves, but that won't present any problems.  Based on our phone conversation all outputs are via the RC-4.

' =========================================================================
'
'   File...... Casket.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... 25 SEP 2008
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


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


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


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

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


' -----[ 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  Baud            = OT2400


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

SYMBOL  relays          = B0
SYMBOL   RedLight       =  BIT0                 ' RC-4 K1
SYMBOL   Fogger         =  BIT1                 ' RC-4 K2
SYMBOL   Lid            =  BIT2                 ' RC-4 K3
SYMBOL   Lifter         =  BIT3                 ' RC-4 K4

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


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

Reset:
  SEROUT Sio, Baud, ("!!!!!RC4", %00, "X")      ' clear relays
  relays = %0000


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

Main:
  timer = 0                                     ' reset timer

Check_Trigger:
  RANDOM lottery                                ' stir random #
  PAUSE 5                                       ' loop pad
  timer = timer + 5 * PIR                       ' update timer
  IF timer < 100 THEN Check_Trigger             ' wait for 0.1 sec input

  RedLight = IsOn
  Fogger = IsOn
  GOSUB Set_RC4
  PAUSE 500                                     ' let fog build

  timer = 0

Shake_It:
  Lid = 1 - Lid                                 ' toggle lid output
  GOSUB Set_RC4
  RANDOM lottery
  delay = lottery // 251 + 50                   ' 50 to 300 ms (random)
  PAUSE delay
  timer = timer + delay
  IF timer < 4000 THEN Shake_It                 ' shake for 4 seconds

  Lid = IsOpen                                  ' make sure it's open
  GOSUB Set_RC4
  PAUSE 750                                     ' get lid out of the way

  Lifter = IsUp
  GOSUB Set_RC4
  PAUSE 5000

  Lifter = IsDown
  GOSUB Set_RC4
  PAUSE 750                                     ' let lifter retract

  GOTO Reset


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

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

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


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

vista

Thanks "Jon" I will give that a try and see what happens... I still have to get a few more relays to try it but I'm sure it will work out in the end... I will look over the code and try to determine what each part does...
Somethings I can guess at but a few I'm going to have to work on... I just will run this season with what ever I can get working and next season it will be better...
But like most newbies, I want to start running before walking... Maybe that's just me... most likely...

I'll let you know if I hit anymore sticking points.

You said you were working on a hollywood F/x project.. anything you can tell us about?? Anything good?

Jeff

vista

October 26, 2008, 10:51:00 AM #3 Last Edit: October 26, 2008, 12:20:56 PM by JonnyMac
Hi Jon, I'm working through the pgm and I made a few changes and I'm running into a random length problem.

I am only using the one pneumatic so I changed the code so the lid became the lifter. So now it shakes then opens. 

The problem comes when the fog machine runs for the first time...  The fog machine doesn't quit until the end of it's cycle and It will run the shaking and open 7-9 times before it quits. Below are the changes I made did I opps? and cause it to run on (loop) during the fog?

When the fog is on reheat it (not running) it (shake rattle and roll) only runs once.

I moved the light to k1
the fog machine is on k2
nothing is on k3  (this is where a 2nd PA will go in the future)
and the pneumatic is on k4




' =========================================================================
'
'   File...... Casket.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... 26 OCT 2008
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


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


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


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

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


' -----[ 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  Baud            = OT2400


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

SYMBOL  relays          = B0
SYMBOL   RedLight       =  BIT0                 ' RC-4 K1
SYMBOL   Fogger         =  BIT1                 ' RC-4 K2
SYMBOL   Lid            =  BIT2                 ' RC-4 K3
SYMBOL   Lifter         =  BIT3                 ' RC-4 K4

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


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

Reset:
  SEROUT Sio, Baud, ("!!!!!RC4", %00, "X")      ' clear relays
  relays = %0000


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

Main:
  timer = 0                                     ' reset timer

Check_Trigger:
  RANDOM lottery                                ' stir random #
  PAUSE 5                                       ' loop pad
  timer = timer + 5 * PIR                       ' update timer
  IF timer < 100 THEN Check_Trigger             ' wait for 0.1 sec input

  RedLight = IsOn
  Fogger = IsOn
  GOSUB Set_RC4
  PAUSE 500                                     ' let fog build

  timer = 0

Shake_It:
  Lifter = 1 - Lifter                                 ' toggle lid output
  GOSUB Set_RC4
  RANDOM lottery
  delay = lottery // 251 + 50                   ' 50 to 300 ms (random)
  PAUSE delay
  timer = timer + delay
  IF timer < 4000 THEN Shake_It                 ' shake for 4 seconds

  Lifter = IsOpen                                  ' make sure it's open
  GOSUB Set_RC4
  PAUSE 1750                                     ' get lid out of the way

' Lifter = IsUp
' GOSUB Set_RC4
' PAUSE 2500

  ' = IsDown
' GOSUB Set_RC4
' PAUSE 750                                     ' let lifter retract

  GOTO Reset


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

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

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


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

vista

Also is it the random doing this to me and can we keep it down to 1-3 runs on the program... I really don't want it running 4 or more times...

Jeff

JonnyMac

You didn't say how long the fogger should run....  :'(

... so I'm going to assume (you know what that does) that a 500ms bump of the remote is enough; if not extend that delay before the fogger is shut off.  This version randomizes a variable called "bumps" controls how may times the lid is bumped before it opens.  All timing is randomized to make things interesting.

' =========================================================================
'
'   File...... Casket.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... 25 SEP 2008
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


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


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


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

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


' -----[ 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  Baud            = OT2400


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

SYMBOL  relays          = B0
SYMBOL   RedLight       =  BIT0                 ' RC-4 K1
SYMBOL   Fogger         =  BIT1                 ' RC-4 K2
SYMBOL   Lid            =  BIT2                 ' RC-4 K3
SYMBOL   Lifter         =  BIT3                 ' RC-4 K4

SYMBOL  bumps           = B2

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


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

Reset:
  SEROUT Sio, Baud, ("!!!!!RC4", %00, "X")      ' clear relays
  relays = %0000


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

Main:
  timer = 0                                     ' reset timer

Check_Trigger:
  RANDOM lottery                                ' stir random #
  PAUSE 5                                       ' loop pad
  timer = timer + 5 * PIR                       ' update timer
  IF timer < 100 THEN Check_Trigger             ' wait for 0.1 sec input

  RedLight = IsOn
  Fogger = IsOn
  GOSUB Set_RC4
  PAUSE 500                                     ' let fog build
  Fogger = IsOff
  GOSUB Set_RC4

  RANDOM lottery
  bumps = lottery // 3 + 1                      ' random, 1 to 3

Rattle_Lid:
  Lifter = IsOn                                 ' bump lid
  GOSUB Set_RC4
  RANDOM lottery
  delay = lottery // 101 + 50                   ' 50 to 150 ms (random)
  PAUSE delay
  Lifter = IsOff
  GOSUB Set_RC4
  RANDOM lottery
  delay = lottery // 251 + 100                  ' 100 to 350 ms (random)
  PAUSE delay
  bumps = bumps - 1                             ' update lid bumps
  IF bumps > 0 THEN Rattle_Lid                  ' done?

  Lifter = IsOpen                               ' make sure it's open
  GOSUB Set_RC4
  PAUSE 1750                                    ' get lid out of the way

  GOTO Reset


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

Set_RC4:
  SEROUT Sio, Baud, ("!RC4", %00, "S", relays)
  RETURN
Jon McPhalen
EFX-TEK Hollywood Office

vista

Thanks Jon, The bumps are great and I'm reading the other forum post trying to figure out the random cmd. 

The more I see this the more I refine what I want it to do..

This is the scenario...

The tots have gone through the graveyard and gotten their candy then the casket is below a window that should catch their attention.

Then the PIR will sense them and the program runs...

The lid bumps for 4 secs
Then the lid opens for a 1-2 seconds (I'll set it)
The the lid closes and resets the program until the next victim or passer-by.

It seems like now the casket is random on how many times it runs the program.

It also might be the fog in a enclosed space so I put tape over the Pir when it first gets tripped because I was thinking the fog might be setting of the sensor... It was pretty think in here.

Is the random able to be set to run once so it bumps then opens and closes?

Jeff


JonnyMac

I'm lost: you last two posts -- in my mind -- completely contradict each other.  In one post you say you want the lid to bump 1 to 3 times, not 4 to 9 times as it's doing, and now you want it to run for four seconds.  Which is it?  The programming for these activities as different: you can have random bumping for a given period or you can have a random number of bumps (period will change depending on the number of bumps and randomized delays in between).

Please, just describe the program as you want it to run and I'll write that code.  And be specific; I'm a much better programmer than a mind reader.   ;D  As you can imagine, this is a crazy time of year for us and we're running around like crazy trying to help as many people as we can -- bad information leads to programs that don't work the way you want them to.

I won't be able to get to your program until late tonight or tomorrow, so this gives you a lot of time to write a really good description of exactly how you want this program to behave.  ;)
Jon McPhalen
EFX-TEK Hollywood Office

vista

October 26, 2008, 02:56:46 PM #8 Last Edit: October 27, 2008, 08:41:17 AM by vista
I'm sorry Jon, to me the multiple bumps are a single event that doesn't need to happen more than once per triggered event... (at least until I get better at figuring out what the code is doing)
All the first part for the light and fog machine are perfect and the only part to look at is the lid operation.

This is one triggered event:
I want to have the bumping of the lid for about 4 seconds ...... and then have the lid open all the way for 2 seconds and then close and reset waiting for the next trigger.


I'm also trying to figure out why the process continues for multiple times.  (it bumps the lid then opens and closes and repeats 1-9 times.)  If this is the random playing it's part then I don't want it to do it. 


So in the end I'm trying to do one iteration of lid rattling followed by opening the lid for 2 seconds and then closing until the trigger is tripped again.



Right now I'm trying to decipher the two randoms to see how they affect things. I'm changing the numbers to see how they affect the length of time that the bumps push on the lid.



I hope this is more clear, I realize that this week is crunch time for you helping all the DIYers out there and as we all know we wouldn't have much success without you.


JonnyMac

D'oh!!! There is no delay after reset so the PIR is continuously tripping -- that's easy to fix (I added a one-minute delay in the reset section; adjust as desired).  I also added code that lets the fogger run for 1.5 seconds while the lid is bouncing; you can adjust this if it's too much fog.

' =========================================================================
'
'   File...... Casket.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... 27 OCT 2008
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


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


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


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

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


' -----[ 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  Baud            = OT2400


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

SYMBOL  relays          = B0
SYMBOL   RedLight       =  BIT0                 ' RC-4 K1
SYMBOL   Fogger         =  BIT1                 ' RC-4 K2
SYMBOL   Lid            =  BIT2                 ' RC-4 K3
SYMBOL   Lifter         =  BIT3                 ' RC-4 K4

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


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

Reset:
  SEROUT Sio, Baud, ("!!!!!RC4", %00, "X")      ' clear relays
  relays = %0000

  PAUSE 60000                                   ' 1-minute warm-up/delay


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

Main:
  timer = 0                                     ' reset timer

Check_Trigger:
  RANDOM lottery                                ' stir random #
  PAUSE 5                                       ' loop pad
  timer = timer + 5 * PIR                       ' update timer
  IF timer < 100 THEN Check_Trigger             ' wait for 0.1 sec input

  RedLight = IsOn
  Fogger = IsOn
  GOSUB Set_RC4
  PAUSE 500                                     ' let fog build

  timer = 0

Shake_It:
  Lifter = 1 - Lifter                           ' toggle lid output
  GOSUB Set_RC4
  RANDOM lottery
  delay = lottery // 251 + 50                   ' 50 to 300 ms (random)
  PAUSE delay
  timer = timer + delay

Check_Fogger:
  IF Fogger = IsOff THEN Check_Timer
  IF timer < 1500 THEN Shake_It                 ' 1500 + 500 = 2 secs
    Fogger = IsOff
    GOSUB Set_RC4

Check_Timer:
  IF timer < 4000 THEN Shake_It                 ' shake for 4 seconds

  Lifter = IsOpen                               ' make sure it's open
  GOSUB Set_RC4
  PAUSE 2000                                    ' get lid out of the way

  GOTO Reset


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

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

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


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

vista

That is... What can I say! You are a genius! I'll try to get a video of it made and put it up in the completed section...

Jeff

This Halloween will rock the kids...