November 22, 2024, 02:28:03 PM

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.


Column Popup Program Request

Started by WolfManor, October 27, 2007, 09:38:55 AM

Previous topic - Next topic

WolfManor

Hey Jon!

I hope you are finding time to sleep with all of these last minute requests.  ;D

I am looking to have a "simple" popup in the corner of my cemetary.

Here are the details.

Equipment:
Prop-1
PIR - PIN6
RC-4 - %11 Serial ID
AP-8 - %11 Serial ID

Program Sequence:
1. Wait for Trigger (Victim).

2.  Start one of two sounds (Prefer rotating from one to the other so they never play the same in a row)
*These two sounds are AP-8 Locations 0,3 (Both are 15 seconds in length).

3. In the last 3 seconds of the sound, activate the Fogger (RC-4 - K3) and leave running for 6 seconds. (I would like to be able to tweek this after the final write if possible). 

4. At the end of the sound (or as it is ending) Activate the Flood LIght (RC-4 - K2) until the final reset.  Also Activate the Strobe Light (RC-4 - K1) on a random type effect.  Making the Strobe turn on and off in random intervals so not to have just the standard strobe effect.  More of a lightning type effect.  Leave strobe randomly running until final reset.

5. Activate the Cylinder (OUT0) for the head to pop up.  Remain up for 10 seconds

6. After head goes up, wait 5 seconds and start sound (AP-8 - Location 6).

7. After the sound has played for about 5 seconds (When the head is to go back down) reset all lights and cylinders.  Let the sound finish playing and then do a complete reset.

8. Rest for 25 seconds (I would like to be able to adjust this if possible to do final tweaks).

9. Wait for next "Victim"
Steve

JonnyMac

This will take a little time -- the whole randomly activating the strobe while other items are happening at fixed intervals is a pretty serious programming challenge.
Jon McPhalen
EFX-TEK Hollywood Office

JonnyMac

October 27, 2007, 12:49:32 PM #2 Last Edit: October 27, 2007, 05:43:03 PM by JonnyMac
Okay, here it is.  My challenge to you is to match my two hours of design/programming time with two hours of study to learn how it works.  While it sounds trivial, mixing randomly timed events with events that have fixed timing can be tough, one is forced to create a pseudo-scheduler with multiple timers -- that's what the Hell_Breaks_Loose section is all about.

I did run this on my desk (with just default AP-8 sound) and I'm pretty sure it works per your description.


' =========================================================================
'
'   File...... Wolf_Column.BS1
'   Purpose...
'   Author.... Jon Williams, 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  Head            = PIN0


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

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

SYMBOL  IsUp            = 1
SYMBOL  IsDown          = 0

SYMBOL  Yes             = 1
SYMBOL  No              = 0

SYMBOL  Baud            = OT2400


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

SYMBOL  status          = B0
SYMBOL   playing        =  BIT7

SYMBOL  relays          = B1
SYMBOL   Strobe         =  BIT8
SYMBOL   Flood          =  BIT9
SYMBOL   Fogger         =  BIT10
SYMBOL   K4             =  BIT11

SYMBOL  aSelect         = B2                    ' audio select bit (0 or 3)
SYMBOL  sfx             = B3                    ' sound file to play
SYMBOL  sTimer          = B4                    ' for strobe, 0.1 sec units

SYMBOL  timer           = W4
SYMBOL  lottery         = W5


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

Reset:
  PINS = %00000000
  DIRS = %00000001

  SEROUT Sio, Baud, ("!!!!!!AP8", 255, "X", "!RC4", 255, "X")

  PAUSE 25000
  timer = 0


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

Main:
  RANDOM lottery                                ' stir random value
  PAUSE 5
  timer = timer + 5 * PIR                       ' update debounce timer
  IF timer < 250 THEN Main                      ' wait for valid signal

  aSelect = aSelect ^ 1 & 1                     ' flip audio selection
  LOOKUP aSelect, (0, 3), sfx
  GOSUB Play_Audio

  LOOKUP aSelect, (15000, 15000), timer         ' adjust delays for sounds
  PAUSE timer

  Fogger = IsOn
  GOSUB Set_Relays

  GOSUB Let_Sound_Finish
  Flood = IsOn
  GOSUB Set_Relays

  Head = IsUp
  timer = 0                                     ' clear timer for tricky code

Hell_Breaks_Loose:
  RANDOM lottery
  PAUSE 95                                      ' tuned for 100 ms loop

Check_Fogger:
  IF timer <> 3000 THEN Check_Audio             ' at 3 second mark?
    Fogger = IsOff                              '  yes, kill fogger
    GOSUB Set_Relays


Check_Audio:
  IF timer <> 5000 THEN Check_Strobe            ' at 5 sec mark?
    sfx = 6                                     ' yes, play #6
    GOSUB Play_Audio

Check_Strobe:
  IF sTimer > 0 THEN Update_StrobeTmr           ' strobe timer expired?
  BRANCH strobe, (Strobe_On, Strobe_Off)        ' yes, update output

Strobe_On:
  strobe = IsOn
  GOSUB Set_Relays
  sTimer = lottery // 3 + 1                     ' 0.1 to 0.3 secs on
  GOTO Check_Hell_Timer

Strobe_Off:
  strobe = IsOff
  GOSUB Set_Relays
  sTimer = lottery // 14 + 7                    ' 0.7 to 2.0 secs off
  GOTO Check_Hell_Timer

Update_StrobeTmr:
  sTimer = sTimer - 1

Check_Hell_Timer:
  timer = timer + 100                           ' update hell timing
  IF timer < 10000 THEN Hell_Breaks_Loose       ' go until 10 seconds

  Head = IsDown
  relays = %0000
  GOSUB Set_Relays

  GOSUB Let_Sound_Finish

  GOTO Reset


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

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

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

Let_Sound_Finish:
  PAUSE 50
  SEROUT Sio, Baud, ("!AP8", %11, "G")
  SERIN  Sio, Baud, status
  IF playing = Yes THEN Let_Sound_Finish
    RETURN

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

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

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


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

WolfManor

Jon,

I love challenges!  I will do just that, but as you can imagine, I would like to put that time into the challenge after Halloween.  ;D  I have been doing that with the couple of other programs you have written for me.  My goal is to write all (or most) of the code for my stuff next year and just have you review it and maybe clean it up a little.  You do have one promis, in that I will get you some video of everything after they are done and in use.

I will download and check it out tonight.  The final paint is drying as we speak and setup is tomorrow (Providing all goes well).

When I was writing that request out I was wondering how you were going to do that random and static value thing.  It is funny how you can visualize everything and then when you go to write it out, you see the possible issues.

------------
AS A SIDE NOTE:  Have you thought about adding a topic in the forums to increase programming or toubleshooting skills?  Maybe a thread that you post samples and problems and lock so people cannot reply publiclly but they can try and figure out the problem with the code or how something works.  Then you post the answer after a few days or couple of weeks.  Maybe allow people to send a message with the answers and see how many get it.  I work in technical support and learn the most from other people's problems.  I know you and I have spoken briefly about this on the phone and you mentioned that you also learn a lot from that type of process.  This may help those of us who want to learn, move forward with things we may never run into with our own stuff.
------------

Thanks for the 2 hours of your time!
Steve

WolfManor

Jon,

Thanks for the program.  I have a question.  In the testing that I am doing with the program, it looks as though the fogger is coming on at the same time as the Flood Light and the Strobe.  Is there a way to get the fogger to come on 3 seconds before the Head comes up, flood light turns on and the strobe start running?

The fogger should go for about 6 seconds, but this can be flexible if needed to go longer.

Let me know if that is possible.

Thanks!
Steve

JonnyMac

Did you adjust the values in the LOOKUP table that drive the delay after your initial sound (0 or 3)?  These should be three seconds shorter than your actual sounds.  This is when the fogger starts, then the program polls the AP-8 to see when it finishes.

Sorry, I forgot to add in a bit of code to kill the fogger three seconds into the "hell" cycle -- it's there now.
Jon McPhalen
EFX-TEK Hollywood Office

WolfManor

Jon,

You should be proud of me.  I did find the Lookup thing and adjusted.  It worked better, but you are right, after I got that working I could not figure out how to turn the fogger off after the time.  I was just going to live with the fogger running full time.

So your challenge is partially completed.  Took about 30 minutes to read that code and figure out the time thing, but so far so good.

By the way, You are the Man!!!   :D

Thanks for the update and so far so good!!!!
Steve

JonnyMac

So is the fogger running properly now?  Congratulate yourself for having the wherewithal to spend time learning what is a moderately-sophisticated program; most prop programs will be much simpler.
Jon McPhalen
EFX-TEK Hollywood Office

WolfManor

Jon,

I finished everything and was able to put the boards and all equipment to final testing.  Everything worked as I asked.  Thanks for the proggie and help.  I knew what I wanted but never realized the complexity.  I have been able to do some minor tweaks and get the timing down perfect.

I will upload some final pictures and get them into the Finished Projects part of the forum. 

Next season I am going to do more programming myself and have you look it over. 

Thanks Obi Wan!

Steve