EFX-TEK

TEK Talk => Prop-1 => Topic started by: confused on October 03, 2007, 09:58:19 AM

Title: I need a program
Post by: confused on October 03, 2007, 09:58:19 AM
I need a program to run a basic coffin jumper prop

I need 1 cylinder to activate along with a light and sound that will raise the prop the light and sound will stop. cylinder 1 needs to hold for the duration

I need cylinder 2 to activate along with light and sound then both cylinders retract and wait

I have your prop 1 strater kit, a pir sensor and an ap 8

I would like some randomization in the timing of the cylinders and the sound ( I still have not figured out the ap8 or audacity program)

thank you Chris
Title: Re: I need a program
Post by: JonnyMac on October 03, 2007, 10:05:26 AM
Do you have multiple sounds in the AP-8, or just one long sound that you'd like to cut-off at some point?  The coding is a bit different for each of these scenarios.  Let me know and I'll whip up a program.

And... what kind of light are you using?  If 120 VAC you'll need a relay connected to the Prop-1 to control it -- the Prop-1 cannot switch 120 VAC circuits.

Finally: Be patient with yourself; you just got your product yesterday, right?  I'm good at this because I've been doing it my whole life; don't worry, it doesn't take a lifetime to learn, in a week or so (with a bit of effort on your part) you'll get it all sorted out.
Title: Re: I need a program
Post by: confused on October 05, 2007, 07:02:15 AM
I will probably have the same sound(creaking door like sound) during cylinder 1 operation when the prop stands up but I think I would like to have different sounds(various taunts) during cylinder 2 operation when prop springs forward

I have not yet figured out the audacity program yet but I am working on it

yes I have relays to activate 120v lights (is it wrong to have the prop1 activate a the relay light as strobe effect or is it better to  simply have it turn on a strobe light)


thank you
Title: Re: I need a program
Post by: JonnyMac on October 05, 2007, 08:32:08 AM
Chris,

I'm still at a loss as to how you want to prop to behave.  I'm assuming that you want to wait for signal from the PIR, then activate the prop -- but how, exactly?  What I'm confused about is the two cylinders... what does each of them do?  I'm certain that one is the lifter, but what about the other?  Is it the lid?  If so, should the sequence be something like:

-- wait for PIR
-- start audio
-- open lid
-- lights on
-- lift prop
-- delay
-- lower prop
-- close lid
-- reset

I'm sorry to be nit-picky but that's really important with programming; as humans, we're really good at making sense of partial information in our language, but computers can not do this -- they need absolute specifics.
Title: Re: I need a program
Post by: confused on October 05, 2007, 10:24:25 AM
sorry about the bad description

what I am going to have is a coffin with body in it when the pir detects victim the body is going to rise up to a standing position (some randomization of time would be good) that will be cylinder 1, sound 1, and light1

while the prop is standing and after a random pause the upper torso and arms are going to spring forward that will be cylinder2 ,random sound2 and light effect 2(possibly a strobe) then all will retract and wait

I hope that makes more sense

thanks chris
Title: Re: I need a program
Post by: JonnyMac on October 05, 2007, 10:35:21 AM
Okay, we're getting there.  How long are the random pauses?  From what minimum value to what maximum value?  I need these numbers to include in the code (which is mostly finished).

The devil is always in the details, and we need to know every aspect of a prop's operation before we can code it.
Title: Re: I need a program
Post by: confused on October 05, 2007, 12:10:54 PM
We should probably have a random pause of about 5 to 10 seconds once the pir has detected someone before the first set of effects

then a random pause of say 2 to 6 seconds while the prop simply stands there before the second set of effects fire and the torso jumps and screams etc.

also we should probably have a pause of say 1 to 2 minutes  between retraction and the next time the prop is ready to go again so it is not constantly cycling and the area the pir is sensing has a chance for the people to clear out. I suppose that timing could be a constant since it would be fairly long

I am hoping that when I see this program it will make more sense to me and perhaps I will be able to tweak any timing  problems my self with out bothering you

thanks again chris
Title: Re: I need a program
Post by: confused on October 05, 2007, 12:25:57 PM
We should also make sure that the torso fully retracts (that would be the second set of effects) before the the prop lies back down (that would be the first set of effects) so it does not conflict with the coffin

or another way to put is that it needs to finish in reverse order of how it started

I hope this makes sense
Title: Re: I need a program
Post by: JonnyMac on October 05, 2007, 01:27:40 PM
More details?  How many sounds are you going to have?  The AP-8 can hold eight -- seven that are 6 seconds long, and one that is 15 seconds long.  Since you want to select a random sound, I need to know the selection range.
Title: Re: I need a program
Post by: JonnyMac on October 05, 2007, 01:59:36 PM
Here's a program that should work -- with detail tweaks:

Program updated 10/14/07

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


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


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


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

SYMBOL  Sio             = 7                     ' SETUP = out; no ULN
SYMBOL  PIR             = PIN6                  ' SETUP = DN
SYMBOL  Light2          = PIN3                  ' OUT3 = light 2 relay
SYMBOL  Light1          = PIN2                  ' OUT2 = light 1 relay
SYMBOL  Torso           = PIN1                  ' OUT1 = torso valve
SYMBOL  Body            = PIN0                  ' OUT0 = body valve


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

SYMBOL  Baud            = OT2400

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

SYMBOL  Yes             = 1
SYMBOL  No              = 0


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

SYMBOL  status          = B0                    ' AP-8 status
SYMBOL   playing        = BIT7

SYMBOL  sfx             = B2                    ' sound to play
SYMBOL  last            = B3                    ' last played
SYMBOL  timer           = W4                    ' for timing and delays
SYMBOL  lottery         = W5                    ' random value


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

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

  SEROUT Sio, Baud, ("!!!!!!!AP8", %00, "X")    ' stop audio if playing
  GOTO Show_Delay


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

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

  timer = lottery // 5001 + 5000                ' delay 5 to 10 secs
  PAUSE timer

  Body = IsOn
  Light1 = IsOn
  sfx = 0
  GOSUB Play_Sound

  RANDOM lottery
  timer = lottery // 2001 + 2000                ' delay 2 to 4 secs
  PAUSE timer

  Torso = IsOn
  Light2 = IsOn
  GOSUB Play_Random_Sound

  RANDOM lottery
  timer = lottery // 4001 + 2000                ' delay 2 to 6 secs
  PAUSE timer

  Light2 = IsOff
  Torso = IsOff
  PAUSE 1500                                    ' allow retraction
  Light1 = IsOff
  Body = IsOff

Show_Delay:
  PAUSE 60000                                   ' one minute
  timer = 0                                     ' clear for PIR debounce
  GOTO Main


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

Play_Random_Sound:
  RANDOM lottery
  sfx = lottery // 8                            ' pick sound, 0 to 7
  IF sfx = last THEN Play_Random_Sound          ' no repeats!

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

Play_Sound:
  SEROUT Sio, Baud, ("!AP8", %00, "P", sfx)
  last = sfx                                    ' save for next time

Let_Sound_Finish:
  PAUSE 100
  SEROUT Sio, Baud, ("!AP8", %00, "G")          ' get status
  SERIN  Sio, Baud, status
  IF playing = Yes THEN Let_Sound_Finish
  RETURN


' -----[ User Data ]-------------------------------------------------------
Title: Re: I need a program
Post by: confused on October 05, 2007, 05:42:26 PM
I 'm guessing now because I still have not figured out the audacity program

I think the first sound effect for cylinder 1 (standing the prop up) will prabably be the same every time some sort of creaking rattle and happen again when the prop retracts

so lets figure that is one 6 second  piece we are left with 6 if I can figure  out the program there is no reason why I cant come up with 6 evil laughs screams or taunts so let say 6 and we wont worry about the 15 second thing this time

by the way please excuse any of this that is misspelled or does not make sense as i am drunk now




Title: Re: I need a program
Post by: JonnyMac on October 05, 2007, 06:03:14 PM
I updated the program so that it starts with sound #0, the randomly chooses one of the others for the second part of the program.
Title: Re: I need a program
Post by: confused on October 14, 2007, 07:51:03 AM
I'm sorry guys but I can't get this program to run
Title: Re: I need a program
Post by: JonnyMac on October 14, 2007, 08:32:54 AM
Grab the program again -- when I updated it I accidentally introduced a sneaky little bug that is hard to find; but I found it and removed it.  I've just tested the program on my desk and it is now working again.  Sorry about the trouble.
Title: Re: I need a program
Post by: confused on October 14, 2007, 09:11:40 AM
loaded it up and tried again but it is not working correctly 

p0 and p2 come on and stay on that is all it does
Title: Re: I need a program
Post by: JonnyMac on October 14, 2007, 09:50:03 AM
I can promise you that the program is working correctly -- I just ran it again and all four outputs get activated in the cycle, and two different sounds play from the AP-8.  Double-check your connections.
Title: Re: I need a program
Post by: confused on October 14, 2007, 09:54:55 AM
what connections the only thing pluged in is the trainer
Title: Re: I need a program
Post by: JonnyMac on October 14, 2007, 10:06:41 AM
That explains it; the program is waiting for the AP-8 to say that it's done.  Since you don't have an AP-8 connected, the program is hanging (in the Let_Sound_Finish section) after attempting to play the first sound.
Title: Re: I need a program
Post by: confused on October 14, 2007, 10:10:17 AM
ok that makes sense
Title: Re: I need a program
Post by: confused on October 14, 2007, 10:14:46 AM
how can I test this program using the prop trainer
Title: Re: I need a program
Post by: JonnyMac on October 14, 2007, 10:21:16 AM
You can temporarily disable two lines of code in the Let_Sound_Finish subroutine - note the apostrophes at the beginning of two lines, starting with SERIN:

Let_Sound_Finish:
  PAUSE 100
  SEROUT Sio, Baud, ("!AP8", %00, "G")          ' get status
  'SERIN  Sio, Baud, status
  'IF playing = Yes THEN Let_Sound_Finish
  RETURN
Title: Re: I need a program
Post by: confused on October 14, 2007, 10:56:43 AM
alright now that works

thank you

I hate to tell you this but I have not even started on the ap8 yet

right now I 'm looking at it and the documentation and I can't tell how to plug it in so I hope your ready for another round of stupid questions after the football game thanks again
Title: Re: I need a program
Post by: JonnyMac on October 14, 2007, 11:17:06 AM
We're here to help -- so ask away.  That said, we do appreciate when our customers actually read the documentation because it tends to support the answers and information we provide here in the forums.  The AP-8 is one of our more sophisticated products and it might take a few minutes for things to sink in, but once they do you'll find it can be a whole lot of fun.

One thing: If you start asking questions specific to the AP-8, start a new thread; this thread has run its course.